I have recently started PHP and Mysql project development on Ubuntu. In one part of the project I need to upload files. But my script is not uploading anything larger than 1 MB nor does it show any error. Smaller files are uploading fine. So I think my script is ok. Besides I have made suitable changes in both php.ini and my.cnf files. Can someone please tell me other possible reasons for this?


You can do it in 2 ways, by editing the php.ini file or using .htaccess

If you edit the php.ini file which is located in /etc/php5/apache2/php.ini

Find the value that says upload_max_filesize and change it to the value you wish, for example here I have a max upload file size of 100M

upload_max_filesize = 100M

Now you also need to edit the post_max_size that PHP will work with through POST, for that we edit the value to whatever you want, I recommend same as upload:

post_max_size = 100M

In the case you wish to do it with .htaccess, simply create this file in the root folder of you web site and add the following lines:

<IfModule mod_php5.c>
    php_value upload_max_filesize 100M
    php_value post_max_size 100M

Note that .htaccess does not work 100% of the time because it depends on Server settings. On your localhost it will work perfectly but if you are hosting on a shared site or an external address, the server might have limits to the max size that can be uploaded.

| improve this answer | |

To show errors in PHP, edit your php.ini file and change:

display_errors = on

Restart your apache server.

Then in your project config.php file (if you have one), add these lines:

/* errors handling */

During development, set display_errors=1 and log_errors=0.
When deployed, change display_errors=0 and log_errors=1.

Then just be periodically checking your log file for any logged errors.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.