upload_max_filesize is going nuts...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

upload_max_filesize is going nuts...

Post by Skara »

Ok, explain this to me. This is in my php.ini:

Code: Select all

upload_max_filesize = 16M
I'm trying to upload a 6mb file and I'm getting the error that it exceeds the upload_max_filesize in php.ini. O.o
To make sure I'm not going nuts with my code, here's the little error thing I've got:

Code: Select all

if ($_FILES['userfile']['error'] != UPLOAD_ERR_OK) {
    switch($_FILES['userfile']['error']) {
      case 1: $err = 'File exceeds upload_max_filesize directive in php.ini.'; break;
      case 2: $err = 'File exceeds MAX_FILE_SIZE directive supplied in html form.'; break;
      case 3: $err = 'File only partially uploaded.'; break;
      case 4: $err = 'No file was uploaded.'; break;
      case 6: $err = 'Missing temporary folder.'; break;
      default: $err = 'Undefined error.'; break;
    }
    err($err);
  }
As I said, I'm getting the first one every time. It worked fine with a 1.5mb file.

Edit: Yes, I restarted apache. Figured I'd better mention that.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

did you make sure that your max post size was adjusted too?
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Yeap, did that too. You think maybe it's something in apache's conf? I've checked through my files but don't see anything.
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

I know the problem, I have it slightly different, however the result is the same.

@ home everything works fine, but at my webhost every file above 1MB results in a page not found.

I ran through all the php settings and couldn't detect a problem with exceeding values.

So the problem must ly elsewhere, if my webhost solves the problem and informs me about it then i'll make sure to post it here too, since it may related.
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

K, here's my update or at least in my favor... I looked through some apache logfiles and for me my problem is that there is a setting in apache (don't know which version) somewhere that limits upload requests to 525K.. So my problem was apache related. :) And i had to figure it out as my Webhost didn't yet... LOL.. Now that's funny they are supposed to be the experts..

I certainly hope someone can use this info if they run into any apache or page cannot be found problems when uploading...
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Could you tell me what the line looked like? I've looked through all my conf files and can't find anything that looks like that.
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

It probably has to do with Linux as an operating system. I found something about:
etc/httpd/conf.d/php.conf

Since I am running NT don't have the exact line where to find it, but i passed this one on to my webhost and they found the file and corrected the setting..

My webhost is running Linux and it caused problems in combo with Apache.

Try checking your Apache error logs. This is what i found there:
Thu Jul 21 16:35:23 2005] [error] [client 213.148.229.41] Requested content-length of 3447790 is larger than the configured limit of 524288, referer: hxxp://xxxxxxx

:)
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Sorry about the long wait, I was on business/vacation. So...

/etc/httpd/conf.d/php.conf isn't the same on every pc. I have:
/etc/apache2/conf/apache2.conf
./commonapache2.conf
./skara.conf
./modules.d/[a few files]

Anyway, I'm not getting any errors at all in apache's error log.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

What's the max filesize you can upload?
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

I really don't know. It works with a ~2mb file but not with a ~6mb.

There's another thing to consider too... I'm uploading a tarball and uncompressing it. It contains a folder full of a few pictures which I then make thumbnails from. In other words...
* Upload tarball and move it.
* Uncompress it with exec('tar xfz $file');
* Loop through each picture and create a thumbnail for it.
Each pic is max 800x600. Each thumbnail is max 200x150.
Could any of that affect it?
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

bump. This is really important. ...Although it may not seem like it given the time between my posts. :P

Does anyone have any idea of where to look?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you are incorrectly handling the images, you could easily run out of memory.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Okay. Time for drastic measures.

1. First, make sure it's not your script. That is, take a well documented example (preferably from the PHP manual), and try uploading a big file.
2. Next, make sure it's not PHP. Reinstall PHP, try several different versions, make sure you get rid of everything (including configuration files). Don't forget to reconfigure PHP to allow bigger uploads.
3. Then, reinstall Apache. Same as 2.
4. Then, reinstall your OS.

:) Hopefully, you'll only get to 2, maybe 3.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

tried using a snip from the manual and got the same error.

I don't see why I should have to reinstall php, though. Shouldn't just changing php.ini do whatever I need to? I have 4.3.11, btw.

ignore above ^

Oh wow. Oh no. I just looked at my phpinfo page rather than open up php.ini and it's different than my config file!!
Yes, I restarted apache. Rebooted my system a couple of times since this started, actually.

Now my problem is, I have only one php.ini (according to slocate). Obviously the real one got named something else or some such. According to phpinfo, it's located at /etc/php/cli-php4. But wait!!! That location doesn't exist!! In fact, slocate can't find anything like cli-php4 anywhere!!
...my bad. Could someone please explain to me how to change this without recompiling php?
Post Reply