IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Apple Discussion :

jai un pb d'upload de fichier sur Mac OS X server


Sujet :

Apple

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    97
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 97
    Points : 64
    Points
    64
    Par défaut jai un pb d'upload de fichier sur Mac OS X server
    Bonsoir,

    Je me permet de vous poser la question car cela reste un tantinet mysterieux pour moi...

    création de la page avec dreamweaver d'ou le code ..

    voila , j'ai un serveur web au boulot qui se trouve être un Xserve ..

    jai un script qui permet de faire un upload de photo ..

    ce script fonctionne sous easyphp, il fonctionne egalement avec une fedora core , mais lorsque j'essaye mon script sur le xserve ca fonctionne pas !!

    mon code doit etre bon pourtant puisqu'il fonctionne sous linux!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    <?php require_once('../../Connections/connect.php'); 
    function replace_dangerous_char($fichierdangereux)
    {
    $resultat=str_replace(" ","_",$fichierdangereux);
    $result=str_replace("'","_",$result);
    $result=str_replace("/","_",$result);
    $result=str_replace("\\","_",$result);
    $result=str_replace(":","_",$result);
    $result=str_replace("*","_",$result);
    $result=str_replace("?","_",$result);
    $result=str_replace("<","_",$result);
    $result=str_replace(">","_",$result);
    $result=str_replace("\"","_",$result);
    $result=str_replace("|","_",$result);
    return $resultat;
    }
    
    $colname_Fiche_p = "-1";
    if (isset($_GET['id_tmp2'])) {
      $colname_Fiche_p = (get_magic_quotes_gpc()) ? $_GET['id_tmp2'] : addslashes($_GET['id_tmp2']);
    }
    mysql_select_db($database_connect, $connect);
    $query_Fiche_p = sprintf("SELECT * FROM fiche, tmp_personne WHERE id_tmp2 = %s AND tmp_personne.id_tmp=fiche.id_tmp", $colname_Fiche_p);
    $Fiche_p = mysql_query($query_Fiche_p, $connect) or die(mysql_error());
    $row_Fiche_p = mysql_fetch_assoc($Fiche_p);
    $totalRows_Fiche_p = mysql_num_rows($Fiche_p);
    
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    
    
    
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "formulaire_envoi_fichier")) {
      if ($cv!="")
      {
    if (!is_uploaded_file($cv))
    	{
    	echo "erreur lors du téléchargement du fichier<br>";
    	}
    else
    	{
    	$fichiercv=replace_dangerous_char($_FILES["cv"]["name"]);
    	copy($cv,"../../images/img/".$fichiercv);
    	}
      }
    
      $updateSQL = sprintf("UPDATE fiche SET photo=%s WHERE id_tmp2=%s ",
                           GetSQLValueString($fichiercv, "text"),
                           GetSQLValueString($_POST['id_tmp2'], "int"));
    					   
    
      mysql_select_db($database_connect, $connect);
      $Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());
    
      $updateGoTo = "main.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      @header(sprintf("Location: %s", $updateGoTo));
    }
    /*
      $updateSQL = sprintf("UPDATE tmp_personne SET photo=%s WHERE id_tmp=%s",
                           GetSQLValueString($_POST['photo'], "text"),
                           GetSQLValueString($_POST['id_tmp'], "int"));
    
      mysql_select_db($database_connect, $connect);
      $Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());
    
      $updateGoTo = "main.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      @header(sprintf("Location: %s", $updateGoTo));
    }
    }*/
    ?>
    
    <form name="formulaire_envoi_fichier" enctype="multipart/form-data" method="POST" action="<?php echo $editFormAction; ?>">
      <input name="id_tmp2" type="hidden" id="id_tmp2" value="<?php echo $row_Fiche_p['id_tmp2']; ?>"  />
      <label></label>
      <br />
      <input name="cv" type="file"  id="cv" size="50" />
    <br>
      <input type="submit" name="bouton_submit" value="Envoyer le fichier">
      <input type="hidden" name="MM_update" value="formulaire_envoi_fichier">
    </form>
    
    <?php
    mysql_free_result($Fiche_p);
    ?>

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    97
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 97
    Points : 64
    Points
    64
    Par défaut
    bon ca fonctionne comme ca !!
    apres avoir essayé une autre methode sur le net , voici ce que j'ai changé
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    
    //on vérifies que le champ est bien rempli:
    if(!empty($_FILES["fichier_choisi"]["name"]))
    {
    	//nom du fichier choisi:
    	$nomFichier    = $_FILES["fichier_choisi"]["name"] ;
    	//nom temporaire sur le serveur:
    	$nomTemporaire = $_FILES["fichier_choisi"]["tmp_name"] ;
    	//type du fichier choisi:
    	$typeFichier   = $_FILES["fichier_choisi"]["type"] ;
    	//poids en octets du fichier choisit:
    	$poidsFichier  = $_FILES["fichier_choisi"]["size"] ;
    	//code de l'erreur si jamais il y en a une:
    	$codeErreur    = $_FILES["fichier_choisi"]["error"] ;
    	
    	//chemin qui mène au dossier qui va contenir les fichiers uplaod:
    	$chemin = "../../images/img/" ;
     
    	if(copy($nomTemporaire, $chemin.$nomFichier))
    		echo("<br>l'upload a réussi<br><a href='main.php'>retour</a>") ;
    	else
    		echo("<br>l'upload a échoué") ;
    }//fin if
    else
    {
    	echo("Vous n'avez pas choisit de fichier!!<br>") ;
    	echo("<a href=\"./modif_FicheP.php\">Retour</a>") ;
    }//fin else
    
      $updateSQL = sprintf("UPDATE fiche SET photo=%s WHERE id_tmp2=%s ",
                           GetSQLValueString($_POST['photo'], "text"),
                           GetSQLValueString($_POST['id_tmp2'], "int"));
    					   
    ?>
    
    <form name="formulaire_envoi_fichier" enctype="multipart/form-data" method="POST" action="<?php echo $editFormAction; ?>">
      <input name="id_tmp2" type="hidden" id="id_tmp2" value="<?php echo $row_Fiche_p['id_tmp2']; ?>"  />
      <label></label>
    inscrire le nom de votre fichier
      avec l'extension <br>
      <input name="photo" type="text" id="photo" value="<?php echo $row_Fiche_p['photo']; ?>" />
      <br />
      <br />
      <input type="file" name="fichier_choisi" />
    <br>
      <input type="submit" name="bouton_submit" value="Envoyer le fichier">
      <input type="hidden" name="MM_update" value="formulaire_envoi_fichier">
    </form>
    
    <?php
    mysql_free_result($Fiche_p);
    ?>
    le probleme de cela c'est que j'ai créé un autre champ photo qui doit etre renseigné pour que ma base de donnée soit renseignée, sinon il me met le chemin complet "C:\images\.."

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Uploader un fichier sur un ftp .
    Par gnia?? dans le forum Entrée/Sortie
    Réponses: 4
    Dernier message: 09/12/2006, 14h13
  2. Upload de fichiers sur FREE
    Par messier79 dans le forum Free
    Réponses: 1
    Dernier message: 11/09/2006, 15h33
  3. Réponses: 3
    Dernier message: 20/04/2006, 23h21
  4. Upload de fichier sur le serveur
    Par krfa1 dans le forum ASP
    Réponses: 9
    Dernier message: 29/11/2005, 13h50
  5. Upload de fichiers sur un ftp
    Par Crazyblinkgirl dans le forum ASP
    Réponses: 10
    Dernier message: 20/06/2004, 11h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo