问题描述
我意识到我的 tmp 文件夹或在/var/www文件夹中创建的 images 文件夹的权限存在某种问题.我知道/var/www最初具有root用户访问权限.我一直在关注一些在线教程,以尝试解决此问题,并将我的权限更改为过去一个小时左右的时间,谁知道谁.
I realize there is some sort of problem with permissions on either my tmp folder or the images folder I created in the /var/www folder. I know that /var/www initially has root access. I have been following some online tutorials to try and fix this issue and have changed my permissions to who knows what over the last hour or so.
当尝试使用PHP/MySQL从HTML表单上载文件时,我收到此错误:
I receive this error when trying to upload a file from an HTML form using PHP/MySQL:
Warning: move_uploaded_file(images/verified-gw.gif): failed to open stream: Permission
denied in /var/www/addscore.php on line 40 Warning: move_uploaded_file(): Unable to move
'/tmp/phpla4QCP' to 'images/verified-gw.gif' in /var/www/addscore.php on line 40 cannot
move uploaded file or something beavis
所以我认为/var/www/images文件夹上的权限不正确,或者 tmp 文件夹上的权限是root,而ubuntu的内核不允许php脚本从此移出根拥有的文件到 images 文件夹,据我所知,该文件夹具有我的用户帐户的权限,并且在该组中没有任何人.
So I think the permissions on either the /var/www/images folder are incorrect or the permissions on the tmp folder are root and the kernel of ubuntu is not letting the php script move from this root owned file to the images folder which has permissions of my user account to my knowledge and is in the group nobody.
我很迷路,任何帮助绝对不胜感激.
I am pretty lost, any help is definitely appreciated.
上面您可以在images文件夹中看到权限的图片,我正在尝试将文件从tmp目录移至其中.
Above you can see a picture of the permissions on the images folder I am trying to move the file from the tmp directory to.
哦,这是失败的PHP脚本:
Oh and here is the PHP script that fails:
if (!empty($screenshot)) {
move_uploaded_file($_FILES['screenshot']['tmp_name'], $target)
or die (' cannot move uploaded file or something beavis');
尊敬的
用户
推荐答案
tl:dr-我输入了此内容:sudo chown -R www-data:www-data /var/www
tl:dr - I typed this: sudo chown -R www-data:www-data /var/www
我不认为这是尝试对tmp目录和此chown chmod进行组合.我认为这只是在更改保存所有LAMP文件的/var/www文件夹上的权限.
I do not think it was a combination of trying to chmod the chown the tmp directory and this. I think it is just changing the permissions on the /var/www folder where all LAMP files are kept.
现在,PHP脚本可以工作,并将图像文件丢到我创建的目录中.如果Ubuntu在用户目录中安装了像这样的LAMP堆栈之类的测试服务器,而不必像学习我的文件那样保护我的文件免受纳粹潜艇的攻击,则会更容易.
Now the PHP script works and tosses the image file in the directory I made. It would be easier if Ubuntu installed test servers like this LAMP stack in the user directory without having to learn file permissions like I am protecting my files from the nazis' submarines.
这篇关于访问被拒绝-PHP move_uploaded_file-Ubuntu LAMP/var/www的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!