choklata Posté 26 Janvier 2007 Partager Posté 26 Janvier 2007 (modifié) bonjour, j'ai un probleme avec une fonction d'upload <?//set these variables-----------------------------------------------------------------$path = "../../images/logos_hotel/"; //path to your targetfolder after your domain$max_size = 500000; //maximum filesize//optionally$domain = $_SERVER["HTTP_HOST"]; //your domainname - change if necessary like "www.wza.be"//------------------------------------------------------------------------------------?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>file upload</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body bgcolor="#FFFFCC" text="#990000" link="#990000" vlink="#990000" alink="#990000" leftmargin="20" topmargin="20" marginwidth="20" marginheight="20"><FORM ENCTYPE="multipart/form-data" ACTION="index.php" METHOD="POST"> <table> <tr valign="baseline"> <td width="76" align="right" nowrap>Nom :</td> <td width="249"><input type="text" name="nom" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Ville :</td> <td><input type="text" name="ville" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Etoiles :</td> <td><input type="text" name="etoiles" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Description :</td> <td> <textarea name="description" cols="35" rows="5" wrap="PHYSICAL" ></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Type :</td> <td><table><tr><td><input type="radio" name="type" value="hotel">Hôtel</td> <td><input type="radio" name="type" value="residence">Résidence</td></tr></table></td> </tr> <tr valign="baseline"> <td nowrap align="right"><strong><font color="#990000" face="Geneva, Arial, Helvetica, sans-serif">IMAGE (jpg/gif) </font></strong><font color="#990000">:</font> <INPUT TYPE="file" NAME="userfile"> <br> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><input type="hidden" name="MM_insert" value="form1" /></td> <td><input type="submit" value="Ajouter"></td> </tr> </table> </form><br><?if (!isset($HTTP_POST_FILES['userfile'])) exit;if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File is too big !</font><br>\n"; exit; }if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) { if (file_exists("../".$path . $HTTP_POST_FILES['userfile']['name'])) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">There already exists a file with this name, please rename your file and try again</font><br>\n"; exit; } $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], "../".$path .$HTTP_POST_FILES['userfile']['name']); if (!$res) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Didn't work, please try again</font><br>\n"; exit; } else { ?><br><p> <?$nom = $_POST['nom'];$ville = $_POST['ville'];$etoiles = $_POST['etoiles'];$description = $_POST['description'];$type = $_POST['type'];$img = $HTTP_POST_FILES['userfile']['name'];$nomimagesss="$path$img"";echo $nomimagesss;/*include "../../../bat_mod/conn.php"; *//*$requete ="INSERT INTO hotel (idhotel,nom,emplacement,etoiles,description,type,image) VALUES ('','$nom','$ville','$etoiles','$description','$type','$nomimagesss')"; $rs=mysql_query($requete);*/?> <font color="#333333" face="Geneva, Arial, Helvetica, sans-serif">Find your file here: <strong><font color="#990000"><a href="http://<? echo $domain; ?>/<? echo "../".$path; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?>" target="_blank"><br> http://<? echo $domain; ?>/<? echo $path; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?><br> </a></font></strong><br> HTML:<br> <font color="#990000"><strong><img src="http://<? echo $domain; ?>/<? echo $path; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?>"></strong></font><br><? $nomimagesss="<img src=\"agence/sej_mod/fileupload/$path$img\">";// $nomimagesss="$path$img"";echo $nomimagesss;include "../../../bat_mod/conn.php";$requete ="INSERT INTO hotel (idhotel,nom,emplacement,etoiles,description,type,image) VALUES ('','$nom','$ville','$etoiles','$description','$type','$nomimagesss')"; $rs=mysql_query($requete);?> <br> BBCode: <font color="#990000"><strong><br> [img ]http://<? echo $domain; ?>/<? echo $path; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?>[/img]</strong></font></font></p><? }echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\"><hr>";echo "Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\n";echo "Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n";echo "Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n";echo "</font>";echo "<br><br><img src=\"http://".$domain."/".$path.$HTTP_POST_FILES['userfile']['name']."\">";} else { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Verkeerd bestandstype, enkel gif, jpg of png !!!</font><br>\n"; exit; }}?></body></html> et cet erreur est generer Warning: copy(../../../images/logos_hotel/CAKEHXZZ.png): failed to open stream: No such file or directory in d:\easyphp1-8\www\minacom\agence\sej_mod\fileupload\upload\index.php on line 75 Didn't work, please try again lorsque je fait : $path = "~off/images/"; //path to your targetfolder after your domain ca marche ! mais je veut pas que le fichier s'upload dans ce repertoire et je cherche d'aide Modifié 26 Janvier 2007 par captain_torche Lien vers le commentaire Partager sur d’autres sites More sharing options...
Portekoi Posté 26 Janvier 2007 Partager Posté 26 Janvier 2007 Bonjour, Essai se chemin : /images/logos_hotel/ Bye Portekoi Lien vers le commentaire Partager sur d’autres sites More sharing options...
choklata Posté 26 Janvier 2007 Auteur Partager Posté 26 Janvier 2007 (modifié) ca ne marche pas Portekoi : Warning: copy(../images/logos_hotel/CAMLOFC7.png): failed to open stream: No such file or directory in d:\easyphp1-8\www\minacom\agence\sej_mod\fileupload\upload\index.php on line 75 Didn't work, please try again lorsque je fait : $path = "~off/images/"; ==> ca marche il ya une fonction: move_upload_file($nomTemporaire, $DESTINATION_FOLDER.$nomFichier; est ce que je peut l'utilser pour deplacer le fichier dans "../../../../imhot/" ? car la repertoire ~off/images/ est proteger par htaccess Modifié 26 Janvier 2007 par choklata Lien vers le commentaire Partager sur d’autres sites More sharing options...
captain_torche Posté 26 Janvier 2007 Partager Posté 26 Janvier 2007 Ton répertoire "logos_hotel" existe bien ? Lien vers le commentaire Partager sur d’autres sites More sharing options...
Portekoi Posté 26 Janvier 2007 Partager Posté 26 Janvier 2007 Donne nuit l'arborescence de ton site depuis la racine.. WWW WWW / Images WWW / Images / logos_hotel Etc.... Portekoi Lien vers le commentaire Partager sur d’autres sites More sharing options...
choklata Posté 26 Janvier 2007 Auteur Partager Posté 26 Janvier 2007 (modifié) le repertoire existe : /httpdocs/images/logos_hotel/ le fichier d'upload est dans : /httpdocs/agence/sej_mod/fileupload/upload/ Modifié 26 Janvier 2007 par choklata Lien vers le commentaire Partager sur d’autres sites More sharing options...
captain_torche Posté 26 Janvier 2007 Partager Posté 26 Janvier 2007 Essaye en remontant d'un répertiore depuis $path : ../../../images/logos_hotel/ Lien vers le commentaire Partager sur d’autres sites More sharing options...
choklata Posté 26 Janvier 2007 Auteur Partager Posté 26 Janvier 2007 ca marche merci Lien vers le commentaire Partager sur d’autres sites More sharing options...
Sujets conseillés
Veuillez vous connecter pour commenter
Vous pourrez laisser un commentaire après vous êtes connecté.
Connectez-vous maintenant