While working with file uploads I kept getting this error:
Warning: Max file size of 2097152 bytes exceeded - file [file_logo] not saved in Unknown on line 0
until by searching it in this forum I found that my problem was the php.ini setting upload_max_filesize = 2M
As you can see I am a good boy, I searched the forum first ;-)
What I didn't find in the forum is this:
Suppose I am cool with a 2M max filesize limit for upload or suppose that I can't change my host's php.ini, HOW do I prevent php to spit out that horrible message I posted above?
What irritates me is that I have included a section of code to check for the file size of my upload which issues a nicely formatted message in case the file is too big (meaning bigger than my $MAX_FILE_SIZE value) but when the user tries to upload a file bigger than my $MAX_FILE_SIZE and at the same time bigger than the upload_max_filesize of php.ini, my own nicely formatted message doesn't show up instead at the very top of my page (before the entire site's template even starts) the message I posted above shows up.
How can I avoid that?
In the Chapter 3. Handling file uploads, the manual says that "As of PHP 4.2.0, you could use $_FILES['userfile']['error'] and plan your logic according to the error codes. Whatever the logic, you should either delete the file from the temporary directory or move it elsewhere."
How do I do that? And how could I avoid the message in question if I was on 4.1.1?