【发布时间】:2012-06-05 02:51:13
【问题描述】:
我正在使用move_uploaded_file() 将图像上传到服务器,但是它给出了通常的错误:
Warning: move_uploaded_file(upload/file.png) [function.move-uploaded-file]:
failed to open stream: No such file or directory in
/home/newuser/public_html/model/account.class.php on line 39
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
'/tmp/phpuLkUgE' to 'upload/file.png' in
/home/newuser/public_html/model/account.class.php on line 39
这是不基于权限的,因为我已将文件夹设置为 777 并具有 root 访问权限,ls -l 正确显示为这样。
755 /home/newuser/public_html/model
755 /home/newuser/public_html/model/account.class.php
777 /home/newuser/public_html/upload
PHP 行
move_uploaded_file($_FILES["photo"]["tmp_name"], "../upload/file.png");
我认为问题归结为所有者/组设置配置不正确.. 不久前,我将所有网站作为子域放在一个帐户中:
/home/olduser/public_html/subdomains/index.html
然后我更改了这一点并创建了一个新用户帐户以更轻松地管理单独的网站,并且只是将文件移动到...
/home/olduser/public_html/subdomains
/home/newuser/public_html/index.html
/home/newuser 中的新文件夹现在归newuser newuser 所有,但我认为 php 可能以nobody olduser 运行,所以这可能导致问题?
我可以尝试什么来解决这个问题?
【问题讨论】:
-
如果您收到
no such file or directory,则似乎临时上传的文件根本不存在,因此上传失败,而不是实际移动文件时出错。发布您的 PHP 代码。 -
@Michael 更新了错误代码以提供更清晰的理解