[ciapug] File Upload

Carl Olsen carl-olsen at mchsi.com
Tue Feb 21 13:52:17 CST 2006


The following error types cannot be handled with a user defined function:
E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR,
E_COMPILE_WARNING, and most of E_STRICT raised in the file where
set_error_handler() is called. 

If errors occur before the script is executed (e.g. on file uploads) the
custom error handler cannot be called since it is not registered at that
time. 

Carl

-----Original Message-----
From: Tony Bibbs [mailto:tony at tonybibbs.com] 
Sent: Tuesday, February 21, 2006 8:20 AM
To: carl-olsen at mchsi.com; ciapug at cialug.org
Subject: Re: [ciapug] File Upload

You mean by calling something like this?

http://us3.php.net/set-error-handler

--Tony

Carl Olsen wrote:
> 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
> 
> _______________________________________________
> ciapug mailing list
> ciapug at cialug.org
> http://cialug.org/mailman/listinfo/ciapug



More information about the ciapug mailing list