0
我有下面的工作腳本,而不是圖像1,圖像2,圖像3,圖像4旁邊的框我想爲每個不同的名稱。是否有捷徑可尋? 在此先感謝! 另外我會把 標題(「Location:thankyou.php」);
exit(); 因爲把這個在之後的那一刻,它只是直接引導到thankyou.php不低於頁面(document.php)添加多個文件PHP
<?php
$max_no_img = 4; // Maximum number of images value to be set here
echo "<form method=post action='' enctype='multipart/form-data'>";
echo "<table border='0' width='400' cellspacing='0' cellpadding='0' align=center>";
for ($i = 1;$i <= $max_no_img;$i++) {
echo "<tr><td>Images $i</td><td>
<input type=file name='images[]' class='bginput'></td></tr>";
}
echo "<tr><td colspan=2 align=center><input type=submit value='Add Image'></td></tr>";
echo "</form> </table>";
while (list($key, $value) = each($_FILES['images']['name'])) {
//echo $key;
//echo "<br>";
//echo $value;
//echo "<br>";
if (!empty($value)) { // this will check if any blank field is entered
$filename = rand(1, 100000) . $value; // filename stores the value
$filename = str_replace(" ", "_", $filename);
$add = "upload/$filename"; // upload directory path is set
copy($_FILES['images']['tmp_name'][$key], $add);
echo $add;
// upload the file to the server
chmod("$add", 0777); // set permission to the file.
}
}
?>
</body>
</html>
你知道PHP嗎? – 2012-03-10 13:39:21
我是一個newby!試圖學習。 – user1257518 2012-03-10 13:42:20