PHP /阿帕奇:上传的JPEG图像文件不正确权限设置 [英] PHP/Apache: Permission settings for uploaded JPEG image files not correct

查看:130
本文介绍了PHP /阿帕奇:上传的JPEG图像文件不正确权限设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装一个LAMP开发服务器,现在还在故障排除一些事情。服务器安装在一台电脑上,我使用Windows笔记本电脑来写我的code和通过Web浏览器测试网站。

I just setup a LAMP development server and am still trouble-shooting some things. The server is installed on one computer and I use a Windows laptop to write my code and test the site via the web browser.

我的文件上传脚本可以在JPEG图像文件被成功上传到服务器上,但是当我尝试在Web浏览器中的图像,权限被拒绝。

My file uploading script works in that JPEG image files are successfully uploaded to the server, but when I try to view the images in the web browser, permission is denied.

我通过服务器检查文件的权限,他们是 600 。我可以通过搭配chmod 777 theimage.jpg 解决这个问题,但是这似乎并不像一个很好的解决办法都没有。

I check the permissions on the file via the server and they are 600. I can fix the issue by chmod 777 theimage.jpg, but this doesn't seem like a good solution at all.

解决方案是否有些事情要与Apache配置?还是有别的东西,我应该做的。

Does the solution have something to do with Apache configuration? Or is there something else I should be doing.

感谢,你,
迈克

Thank-you, Mike

更新

要澄清一下,我可以上传JPEG文件 /无功/网络/测试/图像,但我无法后,才能查看Web浏览器的图像已上传。我的脚本可以在生产服务器(我使用的Dreamhost)上。这使我相信,这个问题是我刚才设置开发服务器。任何反馈是大大AP preciated,哪怕它只是我应该读为更好地了解服务器设置的资源。

To clarify, I am able to upload a JPEG file to /var/www/test/images, but am unable to view the image in the web browser after it has been uploaded. My script works on the production server (I am using Dreamhost). This leads me to believe that the issue is with the development server that I have just setup. Any feedback is greatly appreciated, even if it is just resources that I should read for better understanding the server setup.

推荐答案

您需要更改包含文件,而不仅仅是文件本身的文件夹的权限。使用 sudo的文件模式须藤CHOWN 在包含您要访问的文件所在的目录,然后检查以确保权限凡与 LS -rl 命令更改。用chmod使用的权限应为研究是W 和目录应该读 -rw-的R - 的R - 当LS -rl 如果权限已被更改正确使用命令。另外,如果你还不清楚如何搭配chmod和chown工作的具体检查出的此链接和的此链接

You need to change the permissions on the folder containing the file, not just the file itself. Use sudo chmod and sudo chown on the directory that contains the file you want to access, then check to make sure the permissions where changed with the ls -rl command. The permissions used with chmod should be r and w and the directory should read -rw-r--r-- when the ls -rl command is used if the permissions have been changed correctly. Also, if you are still unclear about the specifics of how chmod and chown work check out this link and this link.

编辑:

键入此:

sudo的搭配chmod -R 666 /无功/网络/测试/图像

或者这样:

须藤搭配chmod A = RW /无功/网络/测试/图像

...做你想做的事情。有关详细解释见下面我最新的评论条目。

... to do what you want to do. For more explanation see my latest comment entry below.

这篇关于PHP /阿帕奇:上传的JPEG图像文件不正确权限设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆