我有一个最简单、最愚蠢的脚本,用于上传文件并在操作后返回成功真假。不知道为什么,突然脚本停止工作给我一个failed to open stream: No such file or directory
错误move_uploaded_file
。这很奇怪,因为我没有更改任何路径、权限,基本上什么都没有。任何提示如何解决这个问题?我是 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}';
}
}
以及来自 stacktrace 的页面:
<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 服务器。