q2a/question2answer — pull request #57 by pupi1985 (2014-06-30 21:44:34+00:00)
Title: Added checks and error displays when exceeding post_max_size and upload_max_filesize limits

This was raised by a user here http://www.question2answer.org/qa/35428

I've explained there what the issue is in detail and the different scenarios that might need to be tackled.

I don't like the idea of repeating code structure in account and admin pages. However, I dislike the idea of adding global functions that turn an $error field on more. Maybe if we were under an MVC framework it would make sense to add that to the controller, but it is not the case.

I have also merged both error messages into one. Letting the user know whether the post_max_size or upload_max_filesize has been exceeded might not make quite a difference. Even the exact value to inform the user as a file limit might be hard to tell (EG: If the user is notified of the maximum file size by means of the upload_max_filesize and the post_max_size happens to be equal or close enough to upload_max_filesize then the user still won't be able to upload a file with a size of upload_max_filesize). So I decided not to get into such a trouble and add a generic message there.

PS: Sorry for so many changes but I had to change the indentation of all the $_POST processing so I thought of also reformatting the code by adding some spaces too