Saving an image does not work with chmod 755, but with 777. What should I do?

I have a website where users can crop images. Usually I save cropped images in a folder with the parameters "755" chmod.

However, when it is equal to 755, it does not work. It works when I chmod to 777, and I think 777 is very unsafe, so I don't want to use it.

What could be wrong?

Ps. The system works like this. There are several photos in the server, PHP allows the user to crop these images, and when they click "Save", they should be saved in the "cropped" folder. It works with 777, but not with 755.

0
php chmod
Jan 11 '13 at 19:40
source share
4 answers

File permissions determine what the file owner can do and what others can do (groups and other countries in the world). You must still indicate the correct owner.

You will probably have to change the owner of the folder to the user of your server (possibly www-data if you are using apache). Then 755 should work.

chown www-data:www-data /cropped 

Edit: Use chown -R if there are subfolders inside /cropped and you also want to change their permissions.

+4
Jan 11 '13 at 19:46
source share

You have already received a response from other users. Therefore, I no longer need to repeat this for you here.

But you must learn what 755 and 777 mean, and not think of it as some level of psuedo security level. 777 does not mean that it is unsafe. And frankly, I do not see an immediate problem with setting up the folder for downloading images as 777.

owner, root, php executer etc. are not equivalent, but may be the same.

These words are based on English, and you should take them according to the English meaning, and not according to any foreign design of the programming world.

The root user as a dictator. Everything he says is coming. No one can say otherwise.

When there is an object, there is an owner user. And you are setting laws regarding what the owner can do: read, write, or execute. You can also establish laws that certain groups can comply with. Finally, you can also set laws for what everyone else can do.

Now the dictator does not turn around, doing ALL the work. The one that PHP runs on can be one person. And whoever owns the file may be different. They can certainly be the same person, but such definitions are not equivalent. Hope you see the difference.

Here is another analogy. Think of a private park. If you allow everyone (i.e. 777) to enter and play in the park, do you pose any security risk? No. If you have a safe, who would you allow? Only yourself (the owner), right? So it will be like 700 in linux permissions. No one else has any permission except you (except the dictator, because he can come to your home, kill you and take your things if he likes it).

+2
Jan 12 '13 at 6:17
source share

755 means that the owner can read / write / perform, groups and everything (public) can only read / execute. Check the credentials of your httpd. 777 does not necessarily mean that it is unsafe, just be sure to disable PHP parsing inside this folder using the .htaccess configuration via -ExecCGI or php_flag engine off or even php.ini (for each folder)

You can try 775 to check if the group settings are enough

0
Jan 11 '13 at 19:43
source share

Your / cropped directory must belong to the user who runs PHP.

This is usually www data, but you need to check your setup.

0
Jan 11 '13 at 19:46
source share



All Articles