使用简单文件上传脚本时出现PHP错误: failed to open stream: No such file or directory

标签 php apache centos

我是 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/

相关文章:

php - 是否可以使用 PHP 使 Apache 重新加载 SSL 证书,而无需 shell 访问?

linux - 在没有 X 服务器的 Centos 5.7 上运行 CutyCapt 时出错

php - Laravel 在特征构造函数中传递参数

php - 查看 mysql 中是否返回行的不同方法?

php - Magento PayPal TLS v1.2 是 cURL 7.29.0 可以还是需要 7.34.0?

linux - 在虚拟机上运行时如何查看 Dask 仪表盘?

python - 无法从外部主机在 TCP 端口建立连接

php - 可疑操作异常 : Invalid Host error

php - 如何在 Ubuntu 14.04 上卸载 LAMP?

python - Django WSGI 路径