2

I let users upload images via safecracker.

The process is very standard:

  1. User submit form (fields: name, email, selected file from users HD)
  2. Safecracker uploads the file into the appropriate directory
  3. Safecracker adds an entry to the submit channel in the database
  4. The users gets redirected to the submit/thanks page
  5. I get a mail announcing the upload

My problem: This only works for files with a certain size. I can confirm, that it is fine for files with the size 840kb and that files with more than 2577kb will not work. Somewhere in between will be the breakpoint, which I haven´t figured out yet.

For the big files EE will just do point 2. The file upload will be fine, but the redirect won´t work. The submit-page will turn blank, as if the browser attempts to redirect, but can´t get the thanks-page to load. 3 and 5 aren´t executed.

I think, I found the error

Fatal error: Out of memory (allocated 49020928) (tried to allocate 4000 bytes)
in www/frogcroc.com/www/system/codeigniter/system/libraries/Image_lib.php on 
line 1246

I assume, that I get this error, because my memory limit on the server is exhausted (shared hosting). I assume, that EE tries to make one of those "internal" thumbnails that are needed for watching the entry in the CP.

I need to know: Are my assumptions right? If yes, what are my options?

I can ask my provider to give me more memory. Question: For how much should I ask, and what kind of memory is it, the PHP image memory? What are the technical terms to describe what I want?

Preferred method: Let the users upload all images, how big they might be, but avoid the memory issue, by not invoking the thumbnail routine. I don´t need to see the picture in the CP entry. I´m fine to just get the file name. Preferrably as part of the mail. How can I change the file-fieldtype in the channel "submit", that shows the thumbnal into a text field, that just shows me the filename?

3 Answers 3

1

Here´s what I did: I iterated til I found the max file size, which is around 2,2 MB. I set this as a limit in the CP file manager in order to avoid, that users can upload bigger files. I also ask users to sumbit images with a least 1200 px width. This will give me a sufficient image quality. This is a very pragmatic solution, that doesn´t solve the problem, but something I can live with. It´s easier to take this route, than to discuss this issue with my hosting company or to upgerade to my own server.

1
  • With the suggestions below you don't need to discuss anything with your hosting company or upgrade your to your server. You just literally create a file called .htaccess and drop that in it. It overrides the settings of Apache for that specific site.
    – Ian Young
    May 9, 2013 at 20:09
0

It sounds like a limit on upload size so I'd check this first. In the control panel go to Tools > Utilities > PHP Info. Search for:

  • post_max_size
  • upload_max_filesize

What are those set to?

5
  • post_max_size 20M, upload_max_filesize 20M, memory_limit 80M
    – awa
    Apr 5, 2013 at 10:35
  • I take it the images are well within those limits?
    – Ian Young
    Apr 5, 2013 at 15:32
  • If you're getting an 'out of memory' error I don't think the problem is the thumbnail generation. If it is the case that it's shared hosting then your hosts are probably overselling or someone on the shared server is guzzling all the available memory. I'm not sure there's much they'd be able to give you specifically unless you /they can increase on a user account basis. Alternatively move up to a VPS which will allow you to protect memory resources a little more.
    – Ian Young
    Apr 5, 2013 at 15:36
  • yes, the images are max 8MB
    – awa
    Apr 9, 2013 at 19:00
  • In that case up the memory_limit to 128MB+. You can do that in the php.ini file (if you have access) or via your .htaccess file. Drop this into your .htaccess file: php_value memory_limit 128M. Let me know if that fixes the issue.
    – Ian Young
    Apr 10, 2013 at 8:41
0

Looks like PHP needs more memory to complete the upload process.

With most hosts you can adjust this in your .htacccess file. Add the following to your file:

php_value memory_limit 128M

If PHP throws the error at 128MB, increase it until you hit a number that works for what you're doing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.