Increase the 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
lawrence_chtan
Forum Newbie
Posts: 22
Joined: Mon Jan 02, 2006 8:20 pm
Location: SINGAPORE

Increase the Upload size

Post by lawrence_chtan »

Greeting to all the guru

I had gone thru all the google search. wonder i miss up any point

My problem:

by default PHP only accept 2MB of data upload size to the Webserver

and notice from the Google search. We just need to change the php.ini. the max_upload_size=2MB but the strange part is. after i restarted the computer. In order to let my OS recognised the php.ini

I still cannot exceed the 2MB. the filesize i gonna upload is about 5.6MB

I m testing it on my XP machine and as well my VM of Win2003, with IIS and MySQL

Lawrence
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

did you make sure your MAX_UPLOAD_SIZE in your HTML form is big enough to allow your file through?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Check your max_execution_time as well.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

edit the php.ini and make sure the upload_max_filesize and post_max_size has the value you wanted.

Code: Select all

; Maximum allowed size for uploaded files.
upload_max_filesize = 16M

; Maximum size of POST data that PHP will accept.
post_max_size = 16M

After changing the php.ini, save it and restart the apache web server to see the effect.

Cheers,
Dibyendra
User avatar
themurph
Forum Commoner
Posts: 76
Joined: Wed Apr 19, 2006 1:56 pm
Contact:

Post by themurph »

I believe you can embed those directives within a php page itself as well.

That way, you can effect the change only on those pages that might require it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That can only partly affect the handling. The php directives must be large enough to handle it before the in-page directive is considered.
User avatar
themurph
Forum Commoner
Posts: 76
Joined: Wed Apr 19, 2006 1:56 pm
Contact:

Post by themurph »

Feyd, Is this true of the memory_limit directive?

I could swear awhile back I had a script that was bombing until I put the
directive ini_set("memory_limit","20M"); in it.

(The php.ini setting was the default 8M)
manjeet
Forum Newbie
Posts: 2
Joined: Thu Apr 27, 2006 12:38 pm
Contact:

Increase Maximum Upload Size

Post by manjeet »

create a .htaccess file and write max_upload_size=2MB.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

memory_limit affects how much RAM each page request can use. It does not affect uploads. It would affect handling of images if you are loading them with GD however.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

via ini_set

Post by dibyendrah »

Dear all,

Can we set the memory limit via ini_set() at run time accroding to the upload size ?

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

Post by feyd »

Unless you're loading the uploaded file into memory, there's little point in fiddling with the memory limit.

Yes, it can be altered, at run time, in the script. If you want to know what directives can be altered where, read the ini core directives page.
Post Reply