8797 sujets

Développement web côté serveur, CMS

Bonjour,

je fais appel à vous, parce que j'arrive pas à trouver la solution à un problème sans doute banal. Je voudrais uploader des images sur mon ftp et également sur ma BDD. Lorsque je met enctype multipart/form-data, l'image est bien uploadée sur mon serveur, mais pas sur ma BDD. Lorsque je l'enlève, l'image est uploadée sur ma BDD mais pas sur mon serveur...J'ai essayé toutes les manipulations possibles et inimaginables mais ma connaissance limitée de php m'empêche peut-être de voir l'essentiel.

Voici mon code

Pour info, include fc.php: <?php
if ($modif == 1) { echo"enregistre_conducteur.php?modif=1"; }
else {echo"enregistre_conducteur.php"; }
?>"




<form     method="post"    action="<?php include('fc.php'); ?>"   onSubmit="return verification()" enctype='multipart/form-data' >  
  <input type="hidden" name="MAX_FILE_SIZE" value="20000000" />  
  <table width="750" border="0">  
    <tr>  
      <td width="240" height="24"><p><strong>Je m'identifie:</strong></p>  
      </td>  
      <td width="500"> </td>  
  </tr>  
  </table>  
    
    <table width="750" border="0">  
    <tr>  
      <td width="240" height="24"><div align="right">Mon nom</div></td>  
      <td width="500"><input name="prenom" type="text" <?php echo "value=\"$prenom\""; ?>   onFocus="javascript:this.value=''" >  
        <input name="nom" type="text" <?php echo "value=\"$nom\""; ?> onFocus="javascript:this.value=''" ></td>  
    </tr>  
 </table>  
   
 <table width="750" border="0">  
    <tr>  
      <td width="240" height="24"><div align="right">Mon pseudo*</div></td>  
      <td width="500"><input type="text" name="pseudo" <?php echo "value=\"$pseudo2\""; ?> ></td>  
    </tr>  
 </table>  
   
 <table width="100%" border="0">  
<tr>  
<td>  

<input   name="fichier_upload" id="fichier_upload" type="file" <?php echo "value=\"$fichier_nom\""; ?> onFocus="javascript:this.value=''"><br>  
   


</table>  




 <table width="750" border="0">  
    <tr>  
      <td height="8"></td>  
    </tr>  
 </table>  
    
 <table width="750" border="0">  
  <tr>  
    <td width="240" height="24"><div align="right">Je choisis un mot de passe*</div></td>  
    <td width="500"><input type="password" name="pwd" <?php echo "value=\"$pwd\""; ?> ></td>  
  </tr>  
 </table>  
    
  <table width="750" border="0">  
  <tr>  
    <td width="240" height="24"><div align="right">Je confirme le mot de passe*</div></td>  
      <td width="500"><input type="password" name="pwd2" <?php echo "value=\"$pwd\""; ?>></td>  
  </tr>  
    
    

 </table>  
<p> </p>  
<p><strong>Pour me joindre:</strong></p>  
<table width="750" border="0">  
  <tr>  
    <td width="240" height="24"><div align="right">Mon adresse mail*      </div></td>  
    <td width="500"><input type="text" name="mail" <?php echo "value=\"$mail\""; ?>></td>  
  </tr>  
</table>  

 <table width="750" border="0">  
  <tr>  
    <td width="240" height="24"><div align="right">Mon téléphone</div></td>  
    <td width="500"><input type="text" name="tel" <?php echo "value=\"$tel\""; ?>></td>  
  </tr>  
 </table>  

   
<p>* champs obligatoires</p>  

<BR>  

<p>  
  <input name="accord" type="checkbox" value="oui" <?php if ($modif != "") {echo"checked"; } else {echo "unchecked"; } ?> >  
  J'accepte que mes coordonnées soient communiquées aux usagers de ce site (dans tous les cas mon adresse mail ne sera pas visible sur le site)<br />  
        Ce site s'engage à ne pas communiquer vos données à toute autre personne que les utilisateurs de ce site.<br />  
        Je decharge les createurs de ce site de toute responsabilité en cas de problème survenu lors du covoiturage.   
    
  <br />  
</p>  
<blockquote>  
  <p>  
    
       <input name="soumettre" type="submit"   value="Valider" >  

</blockquote>  

</form>  
</TD>  
</TR>  

</table>  


</html>  




Je pnese que le action est à l'origine du pb, mais lorsque je met une simple adresse php, il me bloque lupload sur la bdd de la même façon. Lorsque je met action="", je n'ai pas de problème mais dans ce cas je n'arrive pas à modifier les informations et donc ca ne sert à rien.

Merci de votre aide!!

Voici, au cas où, le code php pour lupload d'image:


<html>
<head>
<title>Upload</title>
</head>

<body>



<?php  
 if(!empty($_FILES['fichier_upload']['name']))  
{  
// on récupère les infos du fichier à uploader  
 $fichier_temp = $_FILES['fichier_upload']['tmp_name'];  
$fichier_nom = $_FILES['fichier_upload']['name'];  
  

// on défini les dimensions et le type du fichier  
 list($fichier_larg, $fichier_haut, $fichier_type, $fichier_attr)=getimagesize($fichier_temp);  

// infos de contrôle du fichier  
 $fichier_poids_max = 500000;  
$fichier_h_max = 2448;  
$fichier_l_max = 3264;  

// dossier de destination  
 $fichier_dossier = 'avatar/';  

// extension du fichier  
 $fichier_ext = substr($fichier_nom,strrpos( $fichier_nom, '.')+1);  

// on renomme le fichier  
 $fichier_date = date("ymdhis");  
$fichier_n_nom = $fichier_date.".".$fichier_ext;  

// on vérifie s'il y a bien un fichier à uploader  
 if (!empty($fichier_temp) && is_uploaded_file($fichier_temp))  
{  
// on vérifie le poids du fichier  
 if (filesize($fichier_temp)<$fichier_poids_max)  
{  
// types de fichiers autorises 1=gif / 2=jpg / 3=png  
 if (($fichier_type===1) || ($fichier_type===2) || ($fichier_type===3))  
{  
// on vérifie si l'image n'est pas trop grande  
 if (($fichier_larg<=$fichier_l_max) && ($fichier_haut<=$fichier_h_max))  
{  
// si le fichier est ok, on l'upload sur le serveur  
 if (move_uploaded_file($fichier_temp, $fichier_dossier.$fichier_n_nom))  
{  
echo "Le fichier a été uploadé avec succès<br />";  
echo '<a href="'.$fichier_dossier.$fichier_n_nom.'"><img src="'.$fichier_dossier.$fichier_n_nom.'"></a><br />';  
}  
else  
echo "Le fichier n'a pas pu être uploadé<br />";  
}  
else  
echo "Le fichier est trop grand<br />";  
}  
else  
echo "Le fichier n'a pas le bon format<br />";  
}  
else  
echo "Le fichier est trop lourd<br />";  
}  
else  
echo "Pas de fichier à uploader<br />";  
}  
?>  

 </td>  
</tr>  
</table>  
</body>  
</html>

Modifié par willix (28 Jan 2013 - 10:00)
Bonjour,

Essaye d'éditer ton message et d'utiliser les balises [ code ] stp.

Cordialement, Zooz