Problem With Larger Image Uploads

I have a problem uploading some images.

If I try to upload an image of 2.5mb and dimensions of 4000 x 3000 it will not upload and just goes to a 'HTTP 500 Internal Server Error' Page at action/file/upload. It does not even show an 'upload failed' error.

If I try to upload an image of 7 mb and dimensions of 3444 x 2287 it will upload OK.

I changed the .ataccess file to # upload_max_filesize is the maximum size of a single uploaded file (10 MB) but is there a setting for the maximum dimensions of an image or something?    

  • You need to increase both upload_max_filesize and post_max_size.

  • @Juho

    Thanks for your reply.

    I changed the .htaccess file to..

    # PHP SETTINGS
    <IfModule mod_php5.c>
     # limit the maximum memory consumed by the php script to 64 MB
     php_value memory_limit 64M
     # register_globals is deprecated as of PHP 5.3.0 - disable it for security reasons.
     php_value register_globals 0
     # post_max_size is the maximum size of ALL the data that is POST'ed to php at a time (16 MB)
     php_value post_max_size 16777216
     # upload_max_filesize is the maximum size of a single uploaded file (10 MB)
     php_value upload_max_filesize 10485760
     # on development servers, set to 1 to display errors. Set to 0 on production servers.
     php_value display_errors 0
    </IfModule>

    and it still does not upload the larger images.

    I have a test site set up on another server(shared hosting) and it uploads the larger images OK.

    That made me look at the PHP setting on my server(VPS) for this install. I set them to - memory_limit - 64mb. post_max_size 16m. upload_max_filesize 8m.

    But still not working?  

  • Also the images I am trying to upload are only 2.5mb. It seems to be the large dimensions of 4000 x 3000 that are the problem.

    Thanks again for your help Juho.

  • Works Ok on my shared hosting set up though. I thought it might be something to do with permissions or something like that but I don't suppose it would work with smaller dimensions also.

    It wouldn't be so bad if it displayed an error but it just goes to an 500 page.

    I will keep trying!!

    Thanks.

  • Could also be an OOM issue, even though the file itself is within the upload and filesize limits, the plugin creates resized thumbnails from the original, and the memory footprint of that increases with the number of pixels

  • Hi Matt.

    Yes it is a strange one though as I have a test set up on a shared hosting account and it will upload the images ok on there. That makes me think it is my VPS server settings?

    If I resize the image on my pc to 3600px x 2700px it will upload OK.

     

     

  • I have just tried uploading the image to this elgg site and it uploaded ok. I am now looking at server setting.  

  • I suspect a memory limit issue. The memory requirement for image resizing using the GD php extension is depending on image resolution (widget x heigth x number of color channels x bits per channel plus some threshold). The memory requirement can get huge quite easily on larger images as GD creates an uncompressed copy of the image in memory to be able to resize it (even an image with a small file size can fail if it has a large resolution and is highly compressed).

    Are you trying to upload images to the files section of your site or upload images using the Tidypics plugin? In case of uploading using the file plugin the resizing is done with the GD image extension and you won't be able to change that. In case of Tidypics you can switch to ImageMagick or Imagick image libraries as alternatives if available on your server. Both these alternatives to GD have much smaller memory requirements.

    The only thing to allow for larger sized images to upload is to increase memory_limit. Still, you will reach some limit due to limited server memory at some point. Check if increasing memory_limit in .htaccess helps or if you are not allowed to increase it above some limit due to restrictions on the server configuration.

  • Hi iionly.

    At first I thought it was a memory issue but I can upload images of 7.5mb with dimensions of 3600px x 2700px but not 1mb with dimensions of 4000px x 3000px.

    I am trying to upload image to the file section and also the user avatar upload.

    It is just strange that it works ok on my old test set up on shared hosting but not on my new VPS?