By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Any reason why $_FILES['userfile']['error'] wouldn't be populated?

P: n/a
Hi,

I am in the middle of writing an image upload script and am limiting
the size of uploads via upload_max_filesize. This all seems to be
working well, and if I try and upload a bigger file then I get an
UPLOAD_ERR_INI_SIZE sat in $_FILES['userfile']['error']. All hunkey
dorey.

However, in my testing there are one or two large files that cause
problems. PHP appears to abort the upload early as it should, but when
my script runs, $_FILES isn't populated at all?!

I have tried to narrow down the difference in these file but I can't
seem to find anything definate. All the ones that fail are AVI or WMV
files if that gives any clue, but even if I rename them to MPG (others
of which work ok), and check the MIME type being sent up has also
changed to mpg, then they still fail as before. I have sent bigger and
smaller files all ok, so it's not size. I can't see anything in the
filename itself that would cause problems.

Any ideas?

May 27 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 27 May 2007 04:38:47 -0700, lister <li************@hotmail.comwrote:
>I am in the middle of writing an image upload script and am limiting
the size of uploads via upload_max_filesize. This all seems to be
working well, and if I try and upload a bigger file then I get an
UPLOAD_ERR_INI_SIZE sat in $_FILES['userfile']['error']. All hunkey
dorey.

However, in my testing there are one or two large files that cause
problems. PHP appears to abort the upload early as it should, but when
my script runs, $_FILES isn't populated at all?!

I have tried to narrow down the difference in these file but I can't
seem to find anything definate. All the ones that fail are AVI or WMV
files if that gives any clue, but even if I rename them to MPG (others
of which work ok), and check the MIME type being sent up has also
changed to mpg, then they still fail as before. I have sent bigger and
smaller files all ok, so it's not size. I can't see anything in the
filename itself that would cause problems.
Do you have error_reporting set to E_ALL? Are there any errors in the Apache
log? (in case PHP's done something unusual - although it doesn't sound like
it's dumping core). What version of PHP?
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
May 27 '07 #2

P: n/a
Do you have error_reporting set to E_ALL? Are there any errors in the Apache
log? (in case PHP's done something unusual - although it doesn't sound like
it's dumping core). What version of PHP?
--
Andy Hassall :: a...@andyh.co.uk ::http://www.andyh.co.ukhttp://www.and....co.uk/space:: disk and FTP usage analysis tool- Hide
Thanks for your pointers. Yes, I have E_ALL reporting on. On looking
in the Apache error log I found I was getting a error about exceeding
post_max_size on the ones that fail, but bizarrely not on the ones
that work, but yet those are larger!! I can only assume there is some
bug in PHP when checking post_max_size because the large ones that
work are VERY large (2GB) (post_max_size is set to 2M)

OK, so checking the PHP site reveals that what I am experiencing seems
to be correct:
"If the size of post data is greater than post_max_size, the $_POST
and $_FILES superglobals are empty. This can be tracked in various
ways, e.g. by passing the $_GET variable to the script processing the
data, i.e. <form action="edit.php?processed=1">, and then checking if
$_GET['processed'] is set."

Thanks again for your help.
May 27 '07 #3

P: n/a
On 27 May 2007 10:36:10 -0700, lister <li************@hotmail.comwrote:
> Do you have error_reporting set to E_ALL? Are there any errors in the Apache
log? (in case PHP's done something unusual - although it doesn't sound like
it's dumping core). What version of PHP?

Thanks for your pointers. Yes, I have E_ALL reporting on. On looking
in the Apache error log I found I was getting a error about exceeding
post_max_size on the ones that fail, but bizarrely not on the ones
that work, but yet those are larger!!
What enctype do you have on the <formfor the upload? If you don't have
enctype="multipart/form-data", it'll upload it using
application/x-www-form-urlencoded.

Because of this, certain files may be encoded to data several times larger
than their original size - but it depends on the content of the file. Mostly
ASCII files would be closer to their original sizes.
>I can only assume there is some
bug in PHP when checking post_max_size because the large ones that
work are VERY large (2GB) (post_max_size is set to 2M)
With files that large then you quite likely run into various 32-bit integer
limits. Many versions of Apache have issues with 2Gb+ files, let alone PHP.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
May 27 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.