我有一個最簡單的dumbest腳本,用於上傳文件並在操作後返回成功true或false。不知道爲什麼,突然腳本停止工作,在move_uploaded_file
行給我一個failed to open stream: No such file or directory
錯誤。這很奇怪,因爲我沒有改變任何路徑,權限,基本上沒有任何改變。任何提示如何解決這個問題?我是一個PHP新手。我下面的腳本:文件上傳失敗
if(isset($_FILES)){
$file_tmp = $_FILES['mpp-file']['tmp_name'];
$file_name = $_FILES['mpp-file']['name'];
if(is_uploaded_file($file_tmp)) {
if(move_uploaded_file($file_tmp, "tmp/$file_name")){
echo '{"success": true}';
unlink("tmp/$file_name");
} else {
echo '{"success": false}';
}
} else{
echo '{success: false}';
}
}
而且從堆棧跟蹤頁面:
<html>
<head></head>
<body>
<font size="1"><table class="xdebug-error" dir="ltr" border="1" cellspacing="0" cellpadding="1">
<tbody><tr><th align="left" bgcolor="#f57900" colspan="5"><span style="background-color: #cc0000; color: #fce94f; font-size: x-large;">(!)</span> Warning: move_uploaded_file(tmp/MSP1.mpp) [<a href="function.move-uploaded-file">function.move-uploaded-file</a>]: failed to open stream: No such file or directory in K:\LAMP\www\project\msp-load.php on line <i>7</i></th></tr>
<tr><th align="left" bgcolor="#e9b96e" colspan="5">Call Stack</th></tr>
<tr><th align="center" bgcolor="#eeeeec">#</th><th align="left" bgcolor="#eeeeec">Time</th><th align="left" bgcolor="#eeeeec">Memory</th><th align="left" bgcolor="#eeeeec">Function</th><th align="left" bgcolor="#eeeeec">Location</th></tr>
<tr><td bgcolor="#eeeeec" align="center">1</td><td bgcolor="#eeeeec" align="center">0.0034</td><td bgcolor="#eeeeec" align="right">677944</td><td bgcolor="#eeeeec">{main}()</td><td title="K:\LAMP\www\gantt_latest\examples\MSProject_import\msp-load.php" bgcolor="#eeeeec">..\msp-load.php<b>:</b>0</td></tr>
<tr><td bgcolor="#eeeeec" align="center">2</td><td bgcolor="#eeeeec" align="center">0.0034</td><td bgcolor="#eeeeec" align="right">678256</td><td bgcolor="#eeeeec"><a href="http://www.php.net/move_uploaded_file" target="_new">move_uploaded_file</a>
()</td><td title="K:\LAMP\www\project\msp-load.php" bgcolor="#eeeeec">..\msp-load.php<b>:</b>7</td></tr>
</tbody></table></font>
<br>
<font size="1"><table class="xdebug-error" dir="ltr" border="1" cellspacing="0" cellpadding="1">
<tbody><tr><th align="left" bgcolor="#f57900" colspan="5"><span style="background-color: #cc0000; color: #fce94f; font-size: x-large;">(!)</span> Warning: move_uploaded_file() [<a href="function.move-uploaded-file">function.move-uploaded-file</a>]: Unable to move 'K:\LAMP\tmp\phpC7A5.tmp' to 'tmp/MSP1.mpp' in K:\LAMP\www\project\msp-load.php on line <i>7</i></th></tr>
<tr><th align="left" bgcolor="#e9b96e" colspan="5">Call Stack</th></tr>
<tr><th align="center" bgcolor="#eeeeec">#</th><th align="left" bgcolor="#eeeeec">Time</th><th align="left" bgcolor="#eeeeec">Memory</th><th align="left" bgcolor="#eeeeec">Function</th><th align="left" bgcolor="#eeeeec">Location</th></tr>
<tr><td bgcolor="#eeeeec" align="center">1</td><td bgcolor="#eeeeec" align="center">0.0034</td><td bgcolor="#eeeeec" align="right">677944</td><td bgcolor="#eeeeec">{main}()</td><td title="K:\LAMP\www\gantt_latest\examples\MSProject_import\msp-load.php" bgcolor="#eeeeec">..\msp-load.php<b>:</b>0</td></tr>
<tr><td bgcolor="#eeeeec" align="center">2</td><td bgcolor="#eeeeec" align="center">0.0034</td><td bgcolor="#eeeeec" align="right">678256</td><td bgcolor="#eeeeec"><a href="http://www.php.net/move_uploaded_file" target="_new">move_uploaded_file</a>
()</td><td title="K:\LAMP\www\project\msp-load.php" bgcolor="#eeeeec">..\msp-load.php<b>:</b>7</td></tr>
</tbody></table></font>
</body>
</html>
我使用Win7上WAMP服務器。
你是否存在tmp /'文件夾? – slash197