Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
658 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  upload d images

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

upload d images

n°1557288
francescu
youpee !!
Posté le 09-05-2007 à 12:06:28  profilanswer
 

salut,
j ai un soucis qui me laisse perplexe... Un script d upload d images qui fonctionne tres bien, mais seulement sur le pc de l"admin", la majorité des photos ne s'upload pas. J ai fait des tests afin de trouver une correlation mais rien...(taille type etc...). Je recupere les meme photos ppour tester sur une autre machine et la tout marche .....
et je suis perdu  :??:   :??:  
 
pour info : a un enregistrement correspond 1 a 3 images.
 

Code :
  1. <?
  2.                                 // HTTP/1.0
  3. include("./connect.php5" );
  4. //---------------------------------------------------------------------
  5. //-------------------------------------------------------------------------------
  6. //enregistrer un mouveau bien---------------------------------------------------  
  7. if($action == "nouveau" )
  8. {
  9. $query_nv= "insert into bien (nom_bien, type, type_bien, surface, nb_piece, prix,commentaire_1, commentaire_2, departement ,ville, code_postal, coeur, reference) values('$nom_bien','$type','$type_bien', '$surface','$nb_piece', '$prix','$commentaire_1','$commentaire_2','$departement','$ville','$code_postal','$coeur','$reference')";
  10. $result_nv = mysql_query($query_nv);
  11. $id = mysql_insert_id();
  12. //uplaod des images
  13. if ($img_1) {
  14.    if (is_uploaded_file($img_1)) {
  15.    if (move_uploaded_file($img_1, "images/img_admin/" . $id . "_a.jpg" )) {
  16.    chmod("images/img_admin/" . $id . '_a.jpg', 0777);
  17.   }
  18.  }
  19. }
  20. if ($img_2) {
  21.    if (is_uploaded_file($img_2)) {
  22.    if (move_uploaded_file($img_2, "images/img_admin/" . $id . "_b.jpg" )) {
  23.    chmod("images/img_admin/" . $id . "_b.jpg", 0777);
  24.   }
  25.  }
  26. }
  27. if ($img_3) {
  28.    if (is_uploaded_file($img_3)) {
  29.    if (move_uploaded_file($img_3, "images/img_admin/" . $id . "_c.jpg" )) {
  30.    chmod("images/img_admin/". $id ."_c.jpg", 0777);
  31.   }
  32.  }
  33. }
  34. if(!$result_nv) echo "Erreur d'enregistrement";
  35. }
  36. //--------------------------------------------------------------------------
  37. //--------------------------------------------------------------------------
  38. //Mise à jour d'un bien------------------------------------------------  
  39. if($action == "update" )
  40. {
  41. $query_up="update bien set nom_bien='$nom_bien', type='$type', type_bien='$type_bien', surface='$surface', nb_piece='$nb_piece', prix='$prix' , commentaire_1='$commentaire_1', commentaire_2='$commentaire_2', departement='$departement' , ville='$ville', code_postal='$code_postal', coeur='$coeur', reference='$reference' where num_bien='$id';";
  42. $result_up = mysql_query($query_up);
  43.    if(!$result_up) echo "Erreur d'enregistrement";
  44. }
  45. # Traitement du fichier image 1
  46. # --------------------------------------------------------------------------
  47. if ($img_1) {
  48.    if(is_file("images/img_admin/" . $id . "_a.jpg" )) {
  49.     unlink("images/img_admin/" . $id . "_a.jpg" );
  50.    }
  51.    if (is_uploaded_file($img_1)) {
  52.    if (move_uploaded_file($img_1, "images/img_admin/" . $id . "_a.jpg" )) {
  53.    chmod("images/img_admin/" . $id . '_a.jpg', 0777);
  54.   }
  55.  }
  56. }
  57. if ($img_2) {
  58.    if(is_file("images/img_admin/" . $id . "_b.jpg" )) {
  59.     unlink("images/img_admin/" . $id . "_b.jpg" );
  60.    }
  61.    if (is_uploaded_file($img_2)) {
  62.    if (move_uploaded_file($img_2, "images/img_admin/" . $id . "_b.jpg" )) {
  63.    chmod("images/img_admin/" . $id . "_b.jpg", 0777);
  64.   }
  65.  }
  66. }
  67. if ($img_3) {
  68.    if(is_file("images/img_admin/" . $id . "_c.jpg" )) {
  69.     unlink("images/img_admin/" . $id . "_c.jpg" );
  70.    }
  71.    if (is_uploaded_file($img_3)) {
  72.    if (move_uploaded_file($img_3, "images/img_admin/" . $id . "_c.jpg" )) {
  73.    chmod("images/img_admin/". $id ."_c.jpg", 0777);
  74.   }
  75.  }
  76. }
  77. ?>


 
si vous avez une idee....
ps : j ai virer tout firewall et anitvirus mais rien a faire

mood
Publicité
Posté le 09-05-2007 à 12:06:28  profilanswer
 

n°1557381
soju
One shot !
Posté le 09-05-2007 à 14:56:07  profilanswer
 

d'après ce que tu dis ça serait plus un pb coté client, non ?
 
sinon regarde si il y a des erreurs lors du téléchargement :
http://fr2.php.net/manual/fr/featu [...] errors.php

n°1557383
Shinuza
This is unexecpected
Posté le 09-05-2007 à 14:57:36  profilanswer
 

Je suppose que t'as des  
 
<input type="file" name="img_x" />


---------------
Mains power can kill, and it will hurt the entire time you’re dying from it.
n°1557411
francescu
youpee !!
Posté le 09-05-2007 à 15:27:32  profilanswer
 

non aucune erreur n apparait :/
 
voici le form :  

Code :
  1. <form action="detail_bien.php5" name="form" method="post" enctype="multipart/form-data">
  2.         <table width="905" height="88%" border="0" align="left" cellpadding="1" cellspacing="1">
  3.           <tr>
  4.          <td width="131" bgcolor="#E6E8E8" height="26"><div align="left" class="style30"><font size="2">&nbsp;Reference </font>
  5.              <input type="hidden" name="action" value="<?
  6.    if($action=="modifier" ) echo"update";
  7.    elseif($action=="nouveau" ) echo"nouveau"; ?>">
  8.       </div> </td>
  9.        
  10.   <td colspan="3" bgcolor="#E6E8E8"><input type="text" name="reference" size="12" value="<? if($action == "modifier" ) print"$ligne1[reference]";?>" maxlength="12"></td>
  11.          <td width="132" height="26" bgcolor="#E6E8E8"><div align="center" class="style25">type bien </div></td>
  12.          <td width="312" bgcolor="#E6E8E8"><select name="type_bien">
  13.            <option value="1" selected <? if(($action=="modifier" )||($action=="update" )) { if ($ligne1[type_bien] == "villa" ) echo" selected";}?>>Villa</option>
  14.            <option value="2" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[type_bien] == "appartement" ) echo" selected";} ?>>appartement</option>
  15.            <option value="3" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[type_bien] == "maison_village" ) echo" selected";} ?>> maison de village</option>
  16.     <option value="4" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[type_bien] == "terrain" ) echo" selected";} ?>> terrain</option>
  17.     <option value="5" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[type_bien] == "commerce" ) echo" selected";} ?>>commerce</option>
  18.     <option value="6" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[type_bien] == "propriete" ) echo" selected";} ?>> propriete</option>
  19.          </select></td>
  20.           </tr>
  21.         <tr>
  22.         <td width="131" bgcolor="#F5F5F5" height="26"> <div align="left" class="style30"><font size="2">&nbsp;Transaction</font>
  23.  </div></td>
  24.         <td colspan="3" bgcolor="#F5F5F5"><select name="type">
  25.   <option value="1" selected <? if(($action=="modifier" )||($action=="update" )) { if ($ligne1[type] == "location" ) echo" selected";}?>>location</option>
  26.           <option value="2" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[type] == "location_saisonniere" ) echo" selected";} ?>>location_saisonniere</option>
  27.           <option value="3" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[type] == "vente" ) echo" selected";} ?>> vente</option>
  28.         </select></td>
  29.         <td width="132" height="26" bgcolor="#F5F5F5"><div align="center" class="style25"><span class="Style15">Photo n&deg;1<br>
  30.         </span></div></td>
  31.           <td width="312" height="26" bgcolor="#F5F5F5"><input name="img_1" type="file" size="22"></td>
  32.         </tr>
  33.           <tr>
  34.             <td width="131" bgcolor="#E6E8E8" height="26"> <div align="left" class="style30"><font size="2"><font size="2"> &nbsp;Surface</font> </font></div></td>
  35.             <td colspan="3" bgcolor="#E6E8E8"><input type="text" name="surface" size="12" value="<? if($action == "modifier" ) print"$ligne1[surface]";?>" maxlength="12">
  36.               <span class="Style31">metres carr&eacute;s </span></td>
  37.             <td width="132" height="26" bgcolor="#E6E8E8"> <div align="center" class="style25 style26"><span class="Style15">Photo n&deg;2<br>
  38.             </span></div></td>
  39.             <td width="312" height="26" bgcolor="#E6E8E8"><input name="img_2" type="file" size="22"></td>
  40.           </tr>
  41.           <tr>
  42.             <td width="131" bgcolor="#F5F5F5" height="24">
  43.   <div align="left" class="style30"><font size="2"> &nbsp;Nbre de pieces </font></div></td>
  44.             <td bgcolor="#F5F5F5">
  45.  <select name="nb_piece">
  46.           <option value="1" selected <? if(($action=="modifier" )||($action=="update" )) { if ($ligne1[nb_piece] == "1" ) echo" selected";}?>>1</option>
  47.           <option value="2" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[nb_piece] == "2" ) echo" selected";} ?>>2</option>
  48.     <option value="3" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[nb_piece] == "3" ) echo" selected";} ?>>3</option>
  49.      <option value="4" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[nb_piece] == "4" ) echo" selected";} ?>>4</option>
  50.    <option value="5" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[nb_piece] == "5" ) echo" selected";} ?>>5</option>
  51.     <option value="6" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[nb_piece] == "6" ) echo" selected";} ?>>6</option>
  52.      <option value="7" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[nb_piece] == "6+" ) echo" selected";} ?>>6+</option>
  53.             </select>   </td>
  54.             <td bgcolor="#F5F5F5" class="style30"><font size="2">Prix</font></td>
  55.             <td bgcolor="#F5F5F5"><font face="Verdana" size="2">
  56.               <input name="prix" type="text" size="12" maxlength="12" value="<? if($action == "modifier" ) print"$ligne1[prix]";?>">
  57.             </font></td>
  58.             <td height="24" bgcolor="#F5F5F5"> 
  59.             <div align="center" class="style26" ><strong><span class="Style15">Photo n&deg;3</span><br>
  60.             </strong></div></td>
  61.             <td height="24" bgcolor="#F5F5F5"><span class="Style18">
  62.               <input name="img_3" type="file" size="22">
  63.             </span></td>
  64.           </tr>
  65.           <tr>
  66.             <td width="131" height="24" bgcolor="#E6E8E8"> <div align="left" class="style30"><font size="2"> &nbsp;commentaire</font></div></td>
  67.             <td colspan="3" valign="top" bgcolor="#E6E8E8"><font face="Verdana" size="2">
  68.             <textarea name="commentaire_1" cols="40" rows="5"><? if($action == "modifier" ) print"$ligne1[commentaire_1]";?></textarea>
  69.             </font></td>
  70.             <td rowspan="4" bgcolor="#E6E8E8"><div align="center">
  71.             <span class="style25"><font face="Verdana" size="2">Commentaire 2 </font></span> </td>
  72.             <td rowspan="4" bgcolor="#E6E8E8">
  73. <textarea name="commentaire_2" cols="40" rows="6" wrap="VIRTUAL" ><? if($action == "modifier" ) echo"$ligne1[commentaire_2]";?></textarea></td>
  74.           </tr>
  75.           <tr>
  76.             <td width="131" height="24" bgcolor="#F5F5F5">&nbsp;</td>
  77.             <td colspan="3" valign="middle" bgcolor="#F5F5F5">&nbsp;</td>
  78.           </tr>
  79.           <tr>
  80.             <td width="131" bgcolor="#E6E8E8" height="24"> <div align="left" class="style30"><span class="style28">&nbsp;Ville</span></div></td>
  81.             <td width="119" bgcolor="#E6E8E8"><font face="Verdana" size="2">
  82.    <input name="ville" type="text" size="18" maxlength="12" value="<? if($action == "modifier" ) print"$ligne1[ville]";?>">
  83.             </font></td>
  84.             <td width="109" bgcolor="#E6E8E8" class="style25">coup de coeur </td>
  85.             <td width="83" bgcolor="#E6E8E8"><div align="right">
  86.               <select name="coeur">
  87.                 <option value="1" selected <? if(($action=="modifier" )||($action=="update" )) { if ($ligne1[coeur] == "non" ) echo" selected";}?>>non</option>
  88.                 <option value="2" <? if (($action=="modifier" )||($action=="update" )) { if ($ligne1[coeur] == "oui" ) echo" selected";} ?>>oui</option>
  89.               </select>
  90.             </div></td>
  91.           </tr>
  92.           <tr bgcolor="#E6E8E8">
  93.         <td height="25" colspan="4" bgcolor="#F5F5F5">&nbsp;</td>
  94.         </tr>
  95.           <tr bgcolor="cccccc">
  96.             <td height="26" bgcolor="cccccc"></td>
  97.             <td colspan="3" bgcolor="cccccc"><div align="right">
  98.          <input type="submit" name="envoyer" value="Envoyer">   </div></td>
  99.             <td height="26" colspan="2" bgcolor="cccccc">&nbsp;      </td>
  100.           </tr>
  101.         <input type="hidden" name="id" value="<? echo"$id";?>">
  102.         </table>
  103.     </form>  </td> 
  104.   </tr>
  105. </table>


 
a priori certaines personne pensent que ca vient du time limit ou qqchose du genre...

Message cité 1 fois
Message édité par francescu le 09-05-2007 à 15:37:20
n°1557432
soju
One shot !
Posté le 09-05-2007 à 15:58:46  profilanswer
 

francescu a écrit :

non aucune erreur n apparait :/


- y'a quoi qui apparait alors ?
- comme ça a l'air d'être un pb coté client, verifie la config du poste (navigateur, proxy...)
- ajoute un print_r($_FILES); dans ton script histoire d'en savoir un peu plus

n°1557440
francescu
youpee !!
Posté le 09-05-2007 à 16:11:07  profilanswer
 

le passage a la page suivante se fait, sans messages d erreur.
Il n y a pas de proxy. Le poste est autonome avec une connection de 1mo.
je test le print_r ($_FILES)   merci
 

n°1557462
francescu
youpee !!
Posté le 09-05-2007 à 16:40:22  profilanswer
 

euh ca donnerait ca?
 
 

Code :
  1. //uplaod des images
  2. if ($img_1) {
  3.    if (is_uploaded_file($img_1)) {
  4.    if (move_uploaded_file($img_1, "images/img_admin/" . $id . "_a.jpg" )) {
  5.    chmod("images/img_admin/" . $id . '_a.jpg', 0777);
  6.   }
  7.   // pour tester si il ya des  erreurs  
  8.    print_r ($_FILES['$img_1']);
  9.  }
  10. }



Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  upload d images

 

Sujets relatifs
upload d'images qi ne fonctionne pasUpload d'images : jpg->jpg fonctionne mais pas gif->jpg
Help : Check des dimensions d'images lors d'un Uploadgalerie d'images : upload par zip puis extraction par lots
Upload de lots d'images.Fusion de deux images lors d'un upload
Limiter dimension images en uploadProbléme avec un script d'upload d'images
un upload chez free : comment verifier taille des images ? [RESOLU] 
Plus de sujets relatifs à : upload d images


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR