Page 1 of 1

Upload limit somehow still fixed at 2MB

Posted: Tue Aug 30, 2005 8:37 am
by wesley
This is a pet peeve of mine.

upload_max_filesize = 10M
post_max_size = 10M

Both of these are in the php.ini, and I checked that the file's being loaded
and used. I ran the phpinfo script and shows the variables configured as
such.

Even so, I can only upload files up to 2MB big on s9y. Now, I don't think
this is a problem of s9y, but somehow I'm getting limited. I even had
my.cnf made so MySQL would have bigger packet limit. I wrote like this:

[mysqld]
max_allowed_packet=16M

The problem still persisted. Note that by default the size is 1MB, but it
still made me upload a 2MB file, and when I had this change added I
checked from phpMyAdmin that it was applied.

I wonder what the problem is. It's not a timeout issue since I tested it
from within the computer and the upload time is far less than 30 seconds
configured in PHP.

Posted: Wed Aug 31, 2005 12:21 pm
by wesley
Nope, no such thing has been defined or any other conf files that are linked
via 'Include'. Do you think adding that line would help?

Posted: Wed Aug 31, 2005 1:12 pm
by garvinhicking
Also check your memory_limit. Note well that a 2MB JPEG image is resized to a thumbnail and this leads to a full uncompresed image. 2MB JPEG images can easily uncompress to about 16MB, and maybe override your memory_limit of usually 8MB.

Regards,
Garvin

Posted: Mon Sep 05, 2005 5:18 am
by wesley
It's not the problem of memory_limit. I already tried adjusting that before
you made the suggestion. And I was testing uploads with a k3g file (a weird
video clip format for Samsung phones, btw) so decompressing JPEG wasn't
involved in the first place. So basically SOMEWHERE there must be a 2MB
upload limit imposed, even though all indications and settings point out that
the limit is much higher.

I wonder if the mystery could be solved at all...

P.S. The actual upload limit observed is around 2.7MB, btw. None of the
suggested parameters budged this at all.

Posted: Mon Sep 05, 2005 5:50 am
by wesley
AH HA. CULPRIT FOUND.

s9y was imposing the upload limit.

Since s9y was vague about the upload error, I added (in image.inc.php)
$_FILES['userfile']['error']
to the error message and see what error number it gave. It gave '2'.
I looked it up. Apparently it wasn't the problem of the php.ini config,
but the HTML form imposing the limit.

So I searched MAX_FILE_SIZE in the file and lo, I found this:
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
3 million bytes is around 2.86MB. So... basically no matter how high you
set upload_max_filesize, s9y will just limit upload to 2.86MB. This seems
rather shocking because the INSTALLATION routine tells you to increase
the limit to 10MB!

So I removed that line, and tested uploading. And what do you know...
No errors when uploading files up to 10MB! Heh.

You know, I'm going to commit this change to SVN. I'm surprised this
problem was not caught much earlier. There must be a historical reason
the limit was hardcoded there, but it definitely feels contradicting now.

Posted: Mon Sep 05, 2005 12:29 pm
by garvinhicking
Many thanks for spotting this. I didn't even know about that, I ignored it all the time and didn't implement it myself.

So historical reasons did apply - thanks a lot! Would you like to also commit a change to docs/NEWS which tells about this change?

Regards,
Garvin

Posted: Mon Sep 05, 2005 6:49 pm
by wesley
Committed! :)

It is said that imposing the limit from the HTML form should be avoided
when possible because faulty browsers and otherwise mal-intended client
can simply ignore the tag. Instead the intended limit should just be set in
the php.ini file. I wonder if the code came from somewhere else in a
simple cut-and-paste manner... anyway, it's all behind us now.

P.S. I checked the old, old jBlog code and... it was in there since day one.