file permission of an image
In my PHP web server I have written PHP code to upload an image to the server. I have created both thumbnail images. While displaying the image the thumbnail is not displaying. But the actual image is displaying properly. I have checked the server. Here the permission of thumbnail is 640. I want to make it to 777开发者_开发百科. I have set 777 permission to the folder, which contain the thumb image).
Does any one know this?
Thanks in advance
0) 777 is almost certainly wrong. Don't use 777. For example, there's no sane reason to even have the 'execute' bit on for images that I can think of. You also probably don't want the thumbnails to be 'writable' by users other than the one creating it. My best guess is that you really just wanted 'user readable, user writable, world readable': 0644
1) Set the umask() before creating the image, so that the resulting file has the correct permissions. See php.net/umask - assuming you want the aforementioned 'user readable, user writable, world readable', you'd want your umask() to be set to something like 0033.
Even if that's not actually the mode you wanted, umask() should still get you headed the correct direction - but I'd urge you to consider granting the LEAST permissions possible to do the required task, it just makes everything easier.
You can use chmod
function right after creating the thumbnail image:
chmod($thumbnailFile, 0666);
For more information: http://php.net/manual/en/function.chmod.php
精彩评论