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
| <html>
<head><title>upload d'un image de moto</title></head>
<body BACKGROUND="./images/bg_bleu.gif" BGPROPERTIES="fixed" BGCOLOR="Red">
<?php
if(isset($file_name))
{
$dest_rep="images/";
$nom_img="espace_".$_FILES['file_name']['name'];
if (move_uploaded_file($_FILES['file_name']['tmp_name'], $dest_rep.$nom_img))
{
echo "élément transféré<br>";
echo $nom_img;
echo '<a href="ajout.php?nom_img=',$nom_img,'">Suivant</a><br>';
}else{echo("error");}
}
?>
<form enctype="multipart/form-data" action="" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="300000000">
Envoyez ce fichier : <input name="file_name" type="file">
<input type="submit" value="Envoyer le fichier">
</form>
</body>
</html>
la page ajout:
<?php
//---------test
echo $_GET['nom_img'];
echo"<br>";
$photo=$_GET['nom_img'];
echo $photo;
echo"<br>";
print_r($_GET);
echo"<br>";
print_r($_GET['nom_img']);
echo"<br>";
//---------------------fin test
if (isset($_POST['go']) && $_POST['go']=='Enregistrer')
{
mysql_pconnect("localhost","admin","tutu");
mysql_select_db("ol");
//----3 requetes pour trouver $idvehiculev,$idmarquesv,$icaracteristiquesv
mysql_query( 'INSERT INTO tendre VALUES ("'.$idvehiculev.'","'.$idmarquesv.'","'.$icaracteristiquesv.'","","","non","'.$photo.'")')or die ("pb");
mysql_close();
}else{echo"marche pas!!";}
?>
<html>
<head><title>pages test</title></head>
<body BACKGROUND="./images/bg_bleu.gif" BGPROPERTIES="fixed" BGCOLOR="Red">
<form action="ajout.php" method="post">
<table>
<span class="gras">Model :</span>
</td><td>
<input type="text" name="model" maxlength="50" size="50" value="<?php if (isset($_POST['model'])) echo stripslashes(htmlentities(trim($_POST['model']))); ?>">
</td></tr><tr><td>
...........
</td><td>
<textarea name="commentaires" cols="50" rows="10"><?php if (isset($_POST['commentaires'])) echo stripslashes(htmlentities(trim($_POST['commentaires']))); ?></textarea>
</td></tr><tr><td><td align="right">
<input type="submit" name="go" value="Enregistrer">
</td></tr></table>
</form>
</body>
</html> |
Partager