1

I have a front-end entry form using the Guest Entries plugin, with a file input for the user to upload a photo. I am also using the jQuery Form plugin for AJAX submission, but the behavior is the same if I disable it.

The form works great with small file sizes, but if the uploaded image is larger than PHP's upload_max_filesize, I get a fatal error: Imagine\Exception\RuntimeException: Unable to open image.

If the uploaded file is larger than PHP's post_max_size, the page simply reloads - no error is registered. I gather that this error can be difficult to catch, so maybe it's impossible to have a more graceful failure in this case.

However, for file sizes between upload_max_filesize and post_max_size, shouldn't there be a way to return that as a proper error in the errors array, instead of dying in a way that is unhelpful to the end user?

1 Answer 1

1

What's probably happening on both of your cases is a PHP fatal error, which are notoriously difficult to recover from.

The upcoming Craft 3 (thanks to some clever tricks in Yii 2), however does handle fatal PHP error much better and in situations like yours, you would be receiving the actually underlying fatal error message.

1
  • Please see my edit above. After further testing, there are two different issues, depending on whether the file size is larger than upload_max_filesize or post_max_size. The maxUploadFileSize doesn't seem to matter, apart from overriding upload_max_filesize if it is lower. Commented Jan 19, 2015 at 20:13

Your Answer

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

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