0

I have created a upload form It's working fine while I am uploading small files. The html form is not working When I am trying to upload large files. Have you ever experienced this?

Ramesh T
  • 53
  • 1
  • 10
  • 1
    where is your code?? – Saty Apr 28 '15 at 05:33
  • 2
    possible duplicate of [PHP change the maximum upload file size](http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size) – Mike Apr 28 '15 at 05:33
  • 2
    check your upload max size in your `php.ini` file. – Funk Forty Niner Apr 28 '15 at 05:34
  • Thank u so much for your valuable comments.. I have cleared that by changing "post_max_size" in Php.ini file.. In Default it was just 3 mb in my WAMP. I have changed it to 20Mb – Ramesh T May 05 '15 at 04:36

2 Answers2

1

By default, PHP permits a maximum file upload of 2MB. You can ask users to resize their images before uploading but let’s face it: they won’t. Fortunately, we can increase the limit when necessary.

Two PHP configuration options control the maximum upload size: upload_max_filesize and post_max_size. Both can be set to, say, “10M” for 10 megabyte file sizes.

However, you also need to consider the time it takes to complete an upload. PHP scripts normally time-out after 30 seconds, but a 10MB file would take at least 3 minutes to upload on a healthy broadband connection (remember that upload speeds are typically five times slower than download speeds). In addition, manipulating or saving an uploaded image may also cause script time-outs. We therefore need to set PHP’s max_input_time and max_execution_time to something like 300 (5 minutes specified in seconds).

These options can be set in your server’s php.ini configuration file so that they apply to all your applications.if you’re using Apache, you can configure the settings in your application’s .htaccess file:

php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_input_time 300
php_value max_execution_time 300

Finally, you can define the constraints within your PHP application:

ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);

PHP also provides a set_time_limit() function so you don’t need to set max_execution_time directly.

Setting the options in your PHP code is possibly more practical, since you can extend the execution time and increase the file size when your application is expecting a large upload. Other forms would revert to the default 30-second time-out and 2MB limit.

0

Depending on you php version, you could try something like:

ini_set('post_max_size', '32M');
ini_set('upload_max_filesize', '32M');
ini_set('memory_limit', '32M');

just replace "32" with your desired maximum size.

Keep Coding
  • 636
  • 9
  • 26
LPH
  • 1,275
  • 9
  • 16