{"id":6330,"date":"2015-06-12T23:47:38","date_gmt":"2015-06-12T15:47:38","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=6330"},"modified":"2023-04-28T09:47:11","modified_gmt":"2023-04-28T09:47:11","slug":"increase-php-file-upload-size","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/increase-php-file-upload-size\/","title":{"rendered":"How to Increase PHP File Upload Size Limit"},"content":{"rendered":"<p>The default PHP file upload size limit is often set to a low value, which can be insufficient for uploading large files through web applications or content management systems. In this guide, we will show you how to increase the PHP file upload size limit on different platforms.<\/p>\n<h2>Step 1: Locate the php.ini file<\/h2>\n<p>The PHP file upload size limit is configured in the php.ini file. To locate the active php.ini file, run the following command:<\/p>\n<pre>\r\nphp --ini\r\n<\/pre>\n<p>The output will display the location of the php.ini file. If you are using a shared hosting environment, you may need to ask your hosting provider for the location of the php.ini file, or they may provide you with a custom interface to edit the configuration.<\/p>\n<h2>Step 2: Edit the php.ini file<\/h2>\n<p>Open the php.ini file using your preferred text editor. For example, if you are using the nano editor, run:<\/p>\n<pre>\r\nsudo nano \/path\/to\/php.ini\r\n<\/pre>\n<p>Replace \/path\/to\/php.ini with the actual path to your php.ini file.<\/p>\n<h2>Step 3: Update the file upload size limit<\/h2>\n<p>In the php.ini file, locate and modify the following directives:<\/p>\n<pre>\r\nupload_max_filesize = 128M\r\npost_max_size = 128M\r\n<\/pre>\n<p>The values above set the maximum file upload size to 128 MB. Adjust these values according to your requirements.<\/p>\n<h2>Step 4: Increase the script execution time (optional)<\/h2>\n<p>For large file uploads, you may also need to increase the maximum script execution time. Locate and modify the max_execution_time directive in the php.ini file:<\/p>\n<pre>\r\nmax_execution_time = 300\r\n<\/pre>\n<p>The value above sets the maximum script execution time to 300 seconds (5 minutes). Adjust this value according to your needs.<\/p>\n<h2>Step 5: Save and restart the web server<\/h2>\n<p>Save the changes to the php.ini file and restart your web server to apply the new settings.<\/p>\n<p>For Apache:<\/p>\n<pre>\r\nsudo service apache2 restart\r\n<\/pre>\n<p>For Nginx with PHP-FPM:<\/p>\n<pre>\r\nsudo service php-fpm restart\r\nsudo service nginx restart\r\n<\/pre>\n<h2>Programs Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">PHP<\/span> &#8211; A widely-used open-source scripting language, especially suited for web development and can be embedded into HTML.<\/li>\n<li><span class=\"fw-bold\">php.ini<\/span> &#8211; The main configuration file for PHP, which contains settings that control the behavior and functionality of PHP on your server.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>By following this guide, you have successfully increased the PHP file upload size limit on your server. This will enable you to upload larger files through web applications or content management systems that rely on PHP. Remember to adjust the values according to your server&#8217;s resources and requirements to ensure optimal performance.<\/p>\n<p>If you have any questions, comments, or suggestions for improvements, please feel free to share your thoughts. Your feedback helps us provide the most accurate and useful information possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default PHP file upload size limit is often set to a low value, which can be insufficient for uploading large files through web applications or content management systems. In&#8230;<\/p>\n","protected":false},"author":6,"featured_media":6264,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2056,1025],"tags":[1199,1531,1534,1536,1605,1646],"class_list":["post-6330","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cms","category-php","tag-apache","tag-lamp","tag-lemp","tag-linux","tag-nginx","tag-php"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/6330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=6330"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/6330\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/6264"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=6330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=6330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=6330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}