File Upload size

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
khawarikhan
Forum Newbie
Posts: 8
Joined: Tue Feb 15, 2005 3:45 pm

File Upload size

Post by khawarikhan »

Hi Eveybody,
I had posted this message before and someone did reply to the post but that solution didn't work. Actually, I am trying to upload files bigger than 500K on my server. But its not allowing it to upload those files. I checked that I am not passing any variable MAX_FILE_SIZE as a hidden field in the form and have checked the php.ini file and it says that the Max size to upload is 2MB which I set to 5MB now but still it not working. Anyone has any idea how to remedy this problem? Thanks for help

Khawar Khan
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

check the error element of the $_FILES element you are checking against. It may lead you to your answer.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

$_FILES['userfile']['error']
EDIT: Dammit... I was beaten :lol:
khawarikhan
Forum Newbie
Posts: 8
Joined: Tue Feb 15, 2005 3:45 pm

thanks for replying

Post by khawarikhan »

I tried to print this Variable after I hit the upload button, what I see only is........."The page cannot be displayed" error.........it doesn't show anything until the upload file size is less than 500K :(

Khawar
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: thanks for replying

Post by Chris Corbyn »

khawarikhan wrote:I tried to print this Variable after I hit the upload button, what I see only is........."The page cannot be displayed" error.........it doesn't show anything until the upload file size is less than 500K :(

Khawar
Show some code please (and the bit where you echo/print the error element from $_FILES)
khawarikhan
Forum Newbie
Posts: 8
Joined: Tue Feb 15, 2005 3:45 pm

here is the code

Post by khawarikhan »

Code: Select all

if ($save)
{
   if ($Image=="") {
       $upload_message="You have not uploaded any file <br>\n";
   } else {
   if (is_uploaded_file($Image)) {
       $location="LOCATION GOES HERE" . $Image_name;
       copy("$Image", $location);
       $file_error1 = $_FILESї'$Image_name']ї'error'];
       echo "eror1: $file_error1<br>";
       if (file_exists($location)) {
          $upload_message="$Image_name uploaded successfully!<br>";
       } else {
          $upload_message="There was a problem uploading your file to $location. Please check the path and permissions.";
       }
       Header("Location: import.php?filename=$Image_name");
   } else {
       $upload_message="Wrong type of file, please try again!";
   }
   }
}

feyd | please use

Code: Select all

tags while the

Code: Select all

tags are offline![/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

very likely, you are viewing in IE and you didn't send back 256 bytes of data.. IE will display a 404 page if less than 256 bytes are sent back.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

As mentioned in other posts you need to look at post_max_size and file_max_size. If they are each set to some value that is larger than the files you are expecting and the transfer still fails you have another problem.

And here is what your problem may be. There is a flag called LimitRequestBody in Apache that will give the illusion of a configuration error in PHP. This only affects certain installs of Apache and I have seen it happen in Red Hat Linux.

This flag is set to a value in the neighborhood of 500K depending on the installation so if you transfer fails with files that are bigger than ~500K and work with smaller files this may be your problem.

http://www.apacheref.com/ref/http_core/ ... tBody.html

BTW - Even though this page talks about Apache 1.3 I have seen it happen to Apache 2.0.
khawarikhan
Forum Newbie
Posts: 8
Joined: Tue Feb 15, 2005 3:45 pm

RE: smpdawg

Post by khawarikhan »

So how can I increase the size for that then?

Khawar
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

output more characters.. they can be almost anything.. spaces.. carriage returns.. garbage..whatever.. as long as the stream hits 256 or more bytes..
khawarikhan
Forum Newbie
Posts: 8
Joined: Tue Feb 15, 2005 3:45 pm

RE: fyed

Post by khawarikhan »

Sorry for pasting the code without the

Code: Select all

block........I'll do it next times for sure.........
I tried outputting garbage data, a lot of it actually, but still the same error with IE...........page cannot be displayed.........

Khawar
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Re: RE: smpdawg

Post by smpdawg »

khawarikhan wrote:So how can I increase the size for that then?

Khawar
post_max_size is in your php.ini. LimitRequestBody would be in httpd.conf or could be loaded from an external file that httpd.conf is pointing at.

Verify post_max_size and upload_max_filesize in your php.ini before you check the Apache configuration file.


If php.ini looks normal, read this page to get an idea where LimitRequestBody can be. I cannot say for a fact where you will find it because each distro is different.

https://www.redhat.com/archives/taroon- ... 00340.html
Post Reply