Précédent   Forum des professionnels en informatique > Systèmes > Autres systèmes > Mac
Mac Avant de poster: Lire La FAQ Mac; Voir la page Outils; Voir les tutoriels.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 01/05/2008, 00h26   #1
Membre à l'essai
 
Inscription : septembre 2003
Messages : 79
Détails du profil
Informations forums :
Inscription : septembre 2003
Messages : 79
Points : 24
Points : 24
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 :
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);
?>
lolodelp est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/05/2008, 01h06   #2
Membre à l'essai
 
Inscription : septembre 2003
Messages : 79
Détails du profil
Informations forums :
Inscription : septembre 2003
Messages : 79
Points : 24
Points : 24
bon ca fonctionne comme ca !!
apres avoir essayé une autre methode sur le net , voici ce que j'ai changé
Code :
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\.."
lolodelp est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 00h13.


 
 
 
 
Partenaires

Hébergement Web