par
Tazzie » 07 août 2005, 12:39
Salut, alors voila j'ai un code d'upload mais y bug, et je sais pas pourquoi.
Code : Tout sélectionner
<?php
$target = '';
$nom_file = $_FILES['fichier']['name'];
$taille = $_FILES['fichier']['size'];
$tmp = $_FILES['fichier']['tmp_name'];
if(!empty($_POST['posted'])) {
if(move_uploaded_file($_FILES['fichier']['tmp_name'],$target.$_FILES['fichier']['name'])) {
mysql_pconnect("sql.free.fr", "*******" , "*******") or die("erreur");
mysql_select_db("skullnbones") or die("Base de données non trouvée.");
$sql = "INSERT INTO upfile(fichier) VALUES('<a href=\'http://skullnbones.free.fr/".$nom_file."\' target=_blank >~~".$nom_file."~~</a> a été posté par ".$nom."')";
mysql_query($sql) or die (mysql_error()."<br>$sql");
echo "<META HTTP-EQUIV=Refresh CONTENT='0; URL=index.php'>";
} else {
echo 'Merci de remplir tous le champs :)';
}
}
?>
<form enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>" method="POST">
<p style="margin-top: 0; margin-bottom: 0">
<table border="0" width="100%">
<tr>
<td width="20%">
<p style="margin-top: 0; margin-bottom: 0">Fichier: </p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0">Nom : </td>
<td width="80%">
<p style="margin-top: 0; margin-bottom: 0"><input type="hidden" name="posted" value="1" /><input name="fichier1" type="file" />
</p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0"><input type="text" name="nom1" size="20"></td>
</tr>
</table>
<p style="margin-top: 0; margin-bottom: 0"> <br />
<input type="hidden" name="posted" value="1" /><input type="submit" value="Uploader" />
</p>
</form>
Meme si je remplie tous le champs, il me met le message 'Merci de remplir tous le champs

'
Help svp :p
Probleme resolu ! j'avait mis name=fichier1 et name=nom1, il faller pas les 1.
Dsl pour le mot de pass et pour cette erreur bete!

[quote]Salut, alors voila j'ai un code d'upload mais y bug, et je sais pas pourquoi.
[code] <?php
$target = '';
$nom_file = $_FILES['fichier']['name'];
$taille = $_FILES['fichier']['size'];
$tmp = $_FILES['fichier']['tmp_name'];
if(!empty($_POST['posted'])) {
if(move_uploaded_file($_FILES['fichier']['tmp_name'],$target.$_FILES['fichier']['name'])) {
mysql_pconnect("sql.free.fr", "*******" , "*******") or die("erreur");
mysql_select_db("skullnbones") or die("Base de données non trouvée.");
$sql = "INSERT INTO upfile(fichier) VALUES('<a href=\'http://skullnbones.free.fr/".$nom_file."\' target=_blank >~~".$nom_file."~~</a> a été posté par ".$nom."')";
mysql_query($sql) or die (mysql_error()."<br>$sql");
echo "<META HTTP-EQUIV=Refresh CONTENT='0; URL=index.php'>";
} else {
echo 'Merci de remplir tous le champs :)';
}
}
?>
<form enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>" method="POST">
<p style="margin-top: 0; margin-bottom: 0">
<table border="0" width="100%">
<tr>
<td width="20%">
<p style="margin-top: 0; margin-bottom: 0">Fichier: </p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0">Nom : </td>
<td width="80%">
<p style="margin-top: 0; margin-bottom: 0"><input type="hidden" name="posted" value="1" /><input name="fichier1" type="file" />
</p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0"><input type="text" name="nom1" size="20"></td>
</tr>
</table>
<p style="margin-top: 0; margin-bottom: 0"> <br />
<input type="hidden" name="posted" value="1" /><input type="submit" value="Uploader" />
</p>
</form>[/code]
Meme si je remplie tous le champs, il me met le message 'Merci de remplir tous le champs :)'
Help svp :p[/quote]
Probleme resolu ! j'avait mis name=fichier1 et name=nom1, il faller pas les 1.
Dsl pour le mot de pass et pour cette erreur bete! :)