开发者

Image file permission - image resizer

PHP mySQL

Hi, i am having an interesting problem. I have a form in my cms that allows the admin to upload images to the server. The script resizes the images to a thumbnail (170px height)and a large image(600px height). The thumbnails are around 16000k in size and the large images are around 160,000k in size. I do not set file permissions and just let it happen automatically. When i go to the site i can see the thumbnails but i can't see the full size images and i have tracked the problem down to the file permissions. The thumbnails have rw-r-r permissions and the larger images have rw-- -- -- permissions. Ie the public does not have permission to view the large images. I save the large images with the name of the original and i save the thumbnails with _thumbnail appended to the end. Wh开发者_如何学Pythony would the permissions of the large images be different when they are both uploaded and resized by the same script and when i do not set file permissions? Does the size have something to do with it? I only get this problem when uploading images to the production server, not when working on my local machine. Thanks Andrew


How are you resizing the images? Are you using an external program?

This is just a guess, but here goes

  1. admin uploads image.jpg via your form
  2. php script writes uploaded image.jpg to file system as rw- --- --- (600)
  3. php script calls image resizer program to create image_thumbnail.jpg
  4. image resizer writes image_thumbnail.jpg as rw- r-- r-- (644)
  5. php script calls image resizer program to create resized image.jpg
  6. image resizer overwrites image.jpg, but leaves permissions as rw- --- --- (600)

To test this theory, comment out the part where it resizes image.jpg to 600px, and then check the permissions of the originally uploaded image. If they are 600, then there's your problem.

Regardless though, a simple chmod will solve your problem.


I will suggest you to first look at your php.ini file

;Maximum allowed size for uploaded files.
upload_max_filesize = 10M
;Maximum size of POST data that PHP will accept.
post_max_size = 10M

The default settings would be 2M. You will need to change it like I mentioned here. If its still not working please get back.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜