How to increase maximum upload file size in Prestashop
If you're trying to upload a theme/module that has a big package's file size from your Admin Panel on your Prestashop website, you might get an error:
The file is too large. Allowed maximum size is 2 MB.
I don't think this is the first time you've seen this mistake, and it won't be your last. Follow this PrestaShop tutorial for discovering 2 easy solutions to fix the upload_max_filesize error on uploading a commercial module using Module Manager from the modules page in Prestashop Admin Panel instead of asking your hosting provider.
Let's talk we have a new Prestashop module called DocumenThemix. This is one of our latest Prestashop modules helps you create professional, personalised Prestashop documents such as Invoices, Credit Slips or Delivery Slips in PDF that fit your brand, in seconds. It's a great module, and its file size is 7MB.
Sometime, the php configuration puts limits on upload file size. The default settings will restrict this to a max 2 MB upload file size. You need to increase this value to upload your favourite modules & themes (do you know how to install Prestashop Themes?).
First, we need to know about upload_max_filesize and 2 other values.
- Upload_max_filesize - The maximum length of an uploaded record.
- Memory_limit - This units the maximum quantity of memory in bytes that a script is permitted to allocate. This helps prevent poorly written scripts for eating up all to be had memory on a server. Note that to have no memory restriction, set this directive to -1.
- Post_max_size - Sets max size of post records allowed. In case you want to upload large files such as the premium Prestashop themes or Documenthemix module, this value should be large than upload_max_filesize. If reminiscence restriction is enabled by your configure script, memory_limit additionally affects document uploading.
Generally speaking, memory_limit need to be large than post_max_size.
I suggest two methods for fixing this problem.
Edit the php.ini
Open php.ini file at /etc/php/apache2/php.ini or your-root-website/php.ini, search for the following variables and change these to:
memory_limit = 50M
upload_max_filesize = 10M
post_max_size = 10M
Some extra values to edit if you want a higher overall performance of your website on the server:
max_execution_time = 300
max_input_time = 600
memory_limit = 720M
Save the file and restart the Apache web server!
If the first way does not work, or you don't have get right of entry to to the servers file system. For example: your web page is hosted on a commercial web server, then edit the .htaccess file in your website's root.
Add these source codes into your .htaccess
php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M
Save your file and enjoy your time.