Connecting Tech Pros Worldwide Help | Site Map

How to increase the max size of a file upload.

Newbie
 
Join Date: Jun 2009
Posts: 26
#1: Jun 17 '09
Hi, I just want to ask if there is any way I can increase the upload_max_file_size so I can also upoad mp4 file as well as large pdf file.

Thanks in advance.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,747
#2: Jun 17 '09

re: How to increase the max size of a file upload.


Sure. You just have to find the php.ini configuration file being used and edit the value of the directive you want to change.

If you are having problems finding the file, try creating a new .php file and putting <?php phpinfo() ?> into it. That should give you a bunch of info, including a "Loaded Configuration File" value, showing you exactly where the file is.

An alternative method you could try, if your server is running on Apache, is to create a .htaccess file in the directory where your script is, and this into it:
Expand|Select|Wrap|Line Numbers
  1. php_value upload_max_filesize 8M
Newbie
 
Join Date: Jun 2009
Posts: 26
#3: Jun 18 '09

re: How to increase the max size of a file upload.


I found the php.ini and I tried to change the upload_maz_filesize to 200M and the post_max_size to 100M. But still if I upload a file about 3Mb it still does not work.

Thanks..
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,747
#4: Jun 18 '09

re: How to increase the max size of a file upload.


Did you restart the server? Changes to a global php.ini file won't take effect until the server is restarted.
And did the values returned by the phpinfo() function change?

If all that checks out, please elaborate on how the file upload is failing.
What error messages are you getting?
Newbie
 
Join Date: Jun 2009
Posts: 26
#5: Jun 19 '09

re: How to increase the max size of a file upload.


Yup, I already restart my server and the old values returned by the phpinfo change. Even if I test my codes in our hosting not locally. Still the 2Mb and above didn't work. Of course I already change the post and upload max size in our hosting. Do you think its not the php.ini and our hosting have the problem? Is it possible that its with my code?

Thank you very much.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,747
#6: Jun 19 '09

re: How to increase the max size of a file upload.


Are you absolutely sure you are editing the correct php.ini? (A mistake I have made many many times :P)

If the changes in your php.ini aren't being reflected in the phpinfo() function, then your host might be restricting how much you can change.
You might want to ask them about that.

If you are using a local server, then the changes should have been adopted, unless you edited the wrong file, or entered an invalid value, or something.
Reply