[Upload] Problème pour uploader un fichier dans mon code
Salut a vous,
je ne suis pas capable de mettre mon script uploader dans ce script en fat je ne sais pas ou.
Php 4
windows 2003
Code:
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
<?php
if (!isset($_POST['submit']))
{
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
</head>
<body bgcolor="#000000" text="white" vlink="orange" link="white" alink="yellow" >
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
Nom : <input type="text" name="nom"><br>
Date d'affichage : <input type="text" name="affiche"><br>
Courriel : <input type="text" name="courriel"><br>
Évènement : <input type="text" name="evenement"><br>
Date de l' évènement : <input type="text" name="date"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="200000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
}else{
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
</head>
<body bgcolor="#000000" text="white" vlink="black" link="black" alink="black" >
<br><br>
<b>Voici votre résultat <?php echo $_POST['nom']; ?> :</b><hr>
<table border="0" align="center" cellspacing="1" cellpading="0" >
<tr><td bgcolor="#000000" class="white" align="center"><table border=0 align="center" cellspacing="1" cellpading="0" >
<tr><td bgcolor="#cccc99" class="white" align="left" width="500">
Nom : <?php echo $_POST['nom']; ?><br>
Date d'affichage : <?php echo $_POST['affiche']; ?><br>
Courriel : <?php echo $_POST['courriel']; ?><br><br>
Évènement : <?php echo $_POST['evenement']; ?><br>
Date de l' evenement : <?php echo $_POST['date']; ?>
</td>
<td bgcolor="#cccc99" class="white" align="left" width="100"><img src="<?php echo "http://www.test.peuplies.info/AAA Model Editor/upload/".$_POST['uploadedfile']; ?>" width="100" border="0">
</td>
</tr>
</table>
</table>
<br><br>
<hr>
<form action="addtest11write.php?codes=codesource" method="POST">
<center>
<textarea cols="80" rows="20" wrap="off" name="codesource" >
<table border="0" align="center" cellspacing="1" cellpading="0" >
<tr><td bgcolor="#000000" class="white" align="center"><table border="0" align="center" cellspacing="1" cellpading="0" >
<tr><td bgcolor="#cccc99" class="white" align="left" width="500">
Nom : <?php echo $_POST['nom']; ?><br>
Date d'affichage : <?php echo $_POST['affiche']; ?><br>
Courriel : <?php echo $_POST['courriel']; ?><br><br>
Évenement : <?php echo $_POST['evenement']; ?><br>
Date de l' evenement : <?php echo $_POST['date']; ?><br>
</td>
<td bgcolor="#cccc99" class="white" align="left" width="100"><img src="<?php echo "http://www.test.peuplies.info/AAA Model Editor/upload/".$_POST['uploadedfile']; ?>" width="100" border="0">
</td>
</tr>
</table>
</table>
</textarea>
</center>
<input type="submit" name="confirm" value="Confirm">
</form>
</body>
</html>
<?php
}
?> |
Voici mon code pour mon uploader
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
} |