没有此类文件或目录

没有此类文件或目录

本文介绍了使用简单文件上传脚本时发生PHP错误:无法打开流:没有此类文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP n00b,但遵循此出色教程的说明:

I'm a PHP n00b but followed the instructions as per this excellent tut:

不过,尽管这在运行Mac的Mac(OSX 10.8)上运行正常默认的内置Apache,它将失败,并且无法在CentOS 6机器上使用。查看Apache日志,我得到以下信息:

However, whilst this worked perfectly on my Mac (OSX 10.8) running the default built-in Apache, it fails and doesn't work on a CentOS 6 box. Looking through the Apache logs I get this:

failed to open stream: No such file or directory

根目录下的上载文件夹中,权限已设置为 777 > / var / www / html (在Mac上为/ Library / Webserver / Documents)

The permissions have been set to 777 on the "uploads" folder which is in the root of /var/www/html (on the mac it's /Library/Webserver/Documents)

[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中的某些设置以使其能够正常工作

Am I missing some setting in PHP or Apache to enable this to work properly?

非常感谢。

推荐答案

根据您的问题 uploads 文件夹是否在 / var / www / html 中,但是出现错误消息,它试图上载进入 / var / www / html / test / uploads 不存在

According to your question the uploads folder is in /var/www/html, however going by the error message it is trying to upload into /var/www/html/test/uploads which doesn't exist

要么代码上传到正确的路径,或者您需要在测试目录中创建一个上传目录

Either you need to fix the code to upload to the correct path, or you need to create an uploads directory in the test directory

这篇关于使用简单文件上传脚本时发生PHP错误:无法打开流:没有此类文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 16:40