Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy Forums > > >

Solved: php upload restriction


(!)

andynic's Avatar
Computer Specs
Member with 195 posts.
THREAD STARTER
 
Join Date: May 2007
Location: Amsterdam
Experience: Beginner
27-Jun-2012, 10:23 AM #1
Solved: php upload restriction
Hi,

I am using the php function move_uploaded_file to upload files from my computer to a web server.

This script (taken from http://php.net/manual/en/function.ini-get.php) shows the output just below:
<?php
echo 'upload_max_filesize = ' . ini_get('upload_max_filesize') . "<br />";
echo 'post_max_size = ' . ini_get('post_max_size') . "<br />";

echo 'upload_max_filesize = ' . return_bytes(ini_get('upload_max_filesize')) . "<br />";
echo 'post_max_size in bytes = ' . return_bytes(ini_get('post_max_size'));

function return_bytes($val) {
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
switch($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}

return $val;
}
?>
======
Output:
======
upload_max_filesize = 2M
post_max_size = 8M
upload_max_filesize in bytes = 2097152
post_max_size in bytes = 8388608
==========================

Yet, I cannot upload a file that is more than 480K.

If the file is larger, after a wait of several minutes, the browser displays:
Bad Request
Your browser sent a request that this server could not understand.
Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny10 with Suhosin-Patch Server at 127.0.1.1 Port 80

With files smaller than 480K, all goes as it should.

When I test the script that uses the function move_uploaded_file on my development server (uploading files from my computer to my computer), files of several megabytes upload with no problem and the php.ini parameters are set the same on my development server as on the web server in question.

What other parameters or factors might be restricting the upload?

Thanks for your help.
Andynic
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 601 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
27-Jun-2012, 03:18 PM #2
Do you get an error code with that? Not really much to go on otherwise. If not, can you check the error_log? That would give us a bit more to go on, but in the absence of anything else I'd suggest a time out problem with the 480k thing being more of a coincidence.

If we can get a bit more info we could definitely narrow it down though...

Danny
__________________
"An Apple a day keeps the Gatesy at bay"
andynic's Avatar
Computer Specs
Member with 195 posts.
THREAD STARTER
 
Join Date: May 2007
Location: Amsterdam
Experience: Beginner
27-Jun-2012, 03:48 PM #3
HI Danny,

Thanks for the reply.

I realize the info is sketchy, but I don't have privy to that data on the test server. I can only ftp across to where the website's files need to be and then to go in via a web browser. I'll have to try to contact the system manager(s) of the test server.

Andynic
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 601 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
27-Jun-2012, 04:10 PM #4
If you can pull the error_log (or get the sys_ad to do it for you ) that would definitely help resolve things.

Thing that gets me is the 'Bad Request' bit. That doesn't sound like a PHP error to me, that sounds like something being sent in the header that's upsetting the server. Have you tried from another machine / location?

Apart from that mate I'm kind of stumped.

Danny
__________________
"An Apple a day keeps the Gatesy at bay"
andynic's Avatar
Computer Specs
Member with 195 posts.
THREAD STARTER
 
Join Date: May 2007
Location: Amsterdam
Experience: Beginner
27-Jun-2012, 06:04 PM #5
Thanks for the suggestion. I didn't do that but do have some "interesting" new information.

Inspired by your suggestion I tried a different browser. We have standardized on Firefox. I tried Chrome and Safari.

With Chrome (v. 20.0.1132.43) I can upload up to 2MB without a hitch, and that makes sense since the upload_max_size on the server is 2MB.

With Safari (v. 5.1.7) -- same as Chrome

With Firefox (v. 13.0.1), I am still restricted to staying under 480K.

I wonder what it is about Firefox?
Andynic
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 601 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
28-Jun-2012, 04:02 AM #6
Try clearing out the cache and deleting any server related cookies. It's probably not the browser but the data it's sending, and if Chrome and Safari have no problems then it's definitely client side.

Danny
andynic's Avatar
Computer Specs
Member with 195 posts.
THREAD STARTER
 
Join Date: May 2007
Location: Amsterdam
Experience: Beginner
28-Jun-2012, 06:02 AM #7
Thanks for the suggestion.

Just cleared all history, which includes cache and cookies, since Firefox has been in use. Same problem still exists with Firefox (please see more below).

Can also add Opera (v. 12.00) and Internet Explorer (8.0) to the list of browsers where there is no problem.

And now the weirdest of all: It works ok with Firefox (v. 13.0.1) on Windows XP!

My development client/server configuration:
Mac OS X 10.6.8
Apache 2.2.21 (Unix)
PHP Zend Engine v2.3.0
Windows XP runs on the above as a virtual machine in VMware Fusion (v. 3.1.3)

All browsers named were running on the Mac except for IE8 and the Firefox version that worked ok; those last two were running under Windows XP on the virtual machine.
Andynic
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 601 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
29-Jun-2012, 08:53 AM #8
Just a follow up Andy, I Googled issues with FF 13.0.1 and there seem to be quite a few! Upgrading to FF 14 seems to be the way forward, and I didn't even know there was a 14...

I think we can safely say that it's a browser issue now though.

Good Luck

Danny
__________________
"An Apple a day keeps the Gatesy at bay"
andynic's Avatar
Computer Specs
Member with 195 posts.
THREAD STARTER
 
Join Date: May 2007
Location: Amsterdam
Experience: Beginner
29-Jun-2012, 09:09 AM #9
I agree.
Thanks for your interest and help, Danny.
Andynic
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


Tags
file size restrictions, move_uploaded_file, php

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑