Yahoo奇摩知識+ 將於 2021 年 5 月 4 日 (美國東部時間) 終止服務。自 2021 年 4 月 20 日 (美國東部時間) 起,Yahoo奇摩知識+ 網站將會轉為唯讀模式。其他 Yahoo奇摩產品與服務或您的 Yahoo奇摩帳號都不會受影響。如需關於 Yahoo奇摩知識+ 停止服務以及下載您個人資料的資訊,請參閱說明網頁。
PHP多檔上傳=>上傳失敗{到底怎麼回事}
請大大們救救我
這個~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<html>
<head>
<title>表單htm</title>
</head>
<body>
<form action="http://localhost/test.php%22 method="post" enctype="multipart/form-date">
要傳的檔案<br>
檔案一<input type="file" name="file[]" accept="image/gif,image/jpeg"><br>
檔案二<input type="file" name="file[]" accept="image/gif,image/jpeg"><br>
檔案三<input type="file" name="file[]" accept="image/gif,image/jpeg"><br>
<input type='submit' value='傳送'>
</form>
</body>
</html>
~~~~~~~~~~~~~~~~~~~按上傳到~~~~~~~~~~~~~~~~~~~
<?php
$i=count($_FILES["file"]["name"]);
for($j=0;$j<$i;$j++){
if($_FILES["file"]["error"][$j]==0){
if(move_uploaded_file($_FILES["file"]["tmp_name"][$j],"./".$_FILES["file"]["name"][$j])){
echo $_FILES["file"]["name"][$j]."上傳成功<br>";
}else{
echo $_FILES["file"]["name"][$j]."上傳失敗<br>";
}
}
}?>
~~~~~~~~~~~~~~~~~~~~出現這個失敗訊息 ~~~~~~~~~~~~~
101.jpg上傳失敗
mmc.gif上傳失敗
web.gif上傳失敗
PHP Warning: move_uploaded_file(./101.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\test.php on line 5 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\phpE1.tmp' to './101.jpg' in C:\Inetpub\wwwroot\test.php on line 5 PHP Warning: move_uploaded_file(./mmc.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\test.php on line 5 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\phpE2.tmp' to './mmc.gif' in C:\Inetpub\wwwroot\test.php on line 5 PHP Warning: move_uploaded_file(./web.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\test.php on line 5 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\phpE3.tmp' to './web.gif' in C:\Inetpub\wwwroot\test.php on line 5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
請大大救救!感恩!
我有拿掉了可是還是一樣,還有
痾.......我換不同瀏覽器之後,失敗訊息變成這個
PHP Notice: Undefined index: file in C:\Inetpub\wwwroot\test.php on line 2
但還是不知道哪裡有問題
喔耶!
找到了,謝囉
1 個解答
- SamLv 610 年前最佳解答
沒有檔案存取權限???
你試著把「./」拿掉看看。
2011-08-13 09:11:53 補充:
ok!你出現了一個非常重要的訊息:
undefine index ......你使用了非定義的東西。
$_FILES["file"]["name"] ←他沒有被定義。
狀況只有一個,你可能忘記設定
enctype="multipart/form-data"
但事實上你有設。所以.......
請很認真用力的……在
enctype="multipart/form-date"
這一行找出你唯一的一個錯字。
參考資料: 皮老大php敏捷軟體教室