我是 PHP 新手,但按照这个优秀的教程遵循了说明:
PHP Tizag file upload tutorial
然而,虽然这在运行默认内置 Apache 的我的 Mac (OSX 10.8) 上完美运行,但它失败了并且无法在 CentOS 6 机器上运行。通过查看 Apache 日志,我得到了这个:
failed to open stream: No such file or directory
/var/www/html 根目录中的“uploads”文件夹的权限已设置为777(在 mac 上是/Library/网络服务器/文档)
[Tue Apr 30 13:05:11 2013] [error] [client (My IP Address)] PHP Warning: move_uploaded_file(uploads/Today notes.txt): failed to open stream: No such file or directory in /var/www/html/test/uploads3.php on line 8, referer: ht*p://serverip.myserver.com/test/form4.html
[Tue Apr 30 13:05:11 2013] [error] [client (my IP address)] PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpc8AGo8' to 'uploads/Today notes.txt' in /var/www/html/test/uploads3.php on line 8, referer: ht*p://serverip.myserver.com/test/form4.html
我是否缺少 PHP 或 Apache 中的某些设置以使其正常工作?
非常感谢。
最佳答案
根据您的问题,uploads
文件夹位于 /var/www/html
中,但是按照它尝试上传到 /var 的错误消息/www/html/test/uploads
不存在
要么修改代码上传到正确路径,要么在测试目录下创建uploads目录
关于使用简单文件上传脚本时出现PHP错误: failed to open stream: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16299861/