用file上傳檔案,在tmp目錄下找不到檔案

來源:互聯網
上載者:User
代碼如下:


upload.php
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
";

if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
?>

運行結果:
Upload: jdk-6u34-windows-x64.exe
Type: application/octet-stream
Size: 61154.484375 Kb
Temp file: F:\xampp\tmp\phpCB11.tmp

Warning: move_uploaded_file(upload/jdk-6u34-windows-x64.exe): failed to open stream: No such file or directory in F:\xampp\htdocs\test\qwe.php on line 26

Warning: move_uploaded_file(): Unable to move 'F:\xampp\tmp\phpCB11.tmp' to 'upload/jdk-6u34-windows-x64.exe' in F:\xampp\htdocs\test\qwe.php on line 26
Stored in: upload/jdk-6u34-windows-x64.exe

糾結好久了,平台環境是windows平台下安裝XAMPPIntegration Environment
望高手解答,並且想知道是為什麼……


回複討論(解決方案)

目錄 upload 不存在

可能原因:
1.路徑不對。
2.檔案夾沒有許可權。
加 dirname(__FILE__) 看看。


if (file_exists(dirname(__FILE__)."/upload/" . $_FILES["file"]["name"]))

failed to open stream: No such file or directory

哥們兒 你解決了嗎?我在UBUNTU下搭建LAMP環境也出現了一樣的問題 找不到上傳的檔案啊

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.