[ciapug] File Upload
Carl Olsen
carl-olsen at mchsi.com
Mon Feb 20 18:19:42 CST 2006
I ran into an unusual situation today creating a file upload script. I have
the php.ini settings for memory_limit, upload_max_filesize, and
post_max_size all set to 10M. I have a form with a hidden field
MAX_FILE_SIZE just before the file input box set to 10000000 (10 million
bytes, slightly less than 10M). I have a function that checks both the file
extension and the file type, so it only allows files of certain types to be
uploaded. I get unusual results. When I upload most files that do not fit
the required type, it give me one of my custom error messages. When I
upload a file that is too big, it doesn't do anything (MAX_FILE_SIZE
prevents the form from posting). However, when I upload a file with an .exe
file extension that is 54MB, I get a machine error that starts out "PHP
Warning" at the bottom of the page.
What I would really like to do is figure out how to write some PHP code to
intercept the machine error and display a custom error on the page, but it
appears to be outside the scope of any PHP code I can insert into the page.
Has anyone seen this before?
Carl Olsen
More information about the ciapug
mailing list