Skip to content
Eduardo Lira

PRESTASHOP · PHP

Prestashop: "An error has occurred during the file upload" when installing a module or theme

In 2015 I wrote that raising upload_max_filesize was enough. post_max_size was missing, and so was where the change works: php_value in .htaccess brings down sites that run PHP-FPM.

In November 2015 I posted here the explanation for this message, which showed up when uploading a module’s or theme’s .zip through the Prestashop back office:

An error has occurred during the file upload

The most common cause is still the same: the file is larger than PHP’s upload limit, which is 2 MB by default. But the fix I gave was incomplete.

See the current limit

Prestashop shows the limit in effect in the back office, on the administration screen of the advanced preferences, in the “Upload quota” field (the menu path has changed between versions). The value shown there comes from PHP; Prestashop only displays it.

There are two limits, not one

In 2015 I wrote to raise upload_max_filesize, for example to 20 MB. The other one was missing:

upload_max_filesize = 32M
post_max_size = 40M

upload_max_filesize limits each file. post_max_size limits the whole submission, which includes the file and the form’s other fields, and its default is 8 MB. If the submission goes over that limit, PHP discards everything: Prestashop receives an empty form and shows the same generic error. That’s why post_max_size has to be a bit larger than upload_max_filesize.

Where the change works

The right file depends on how PHP runs on the server:

  • Apache with mod_php: you can use the .htaccess at the store’s root.

    php_value upload_max_filesize 32M
    php_value post_max_size 40M
  • PHP-FPM or CGI, the most common setup today: Apache doesn’t recognize php_value, and an .htaccess with those lines takes the store down with a 500 error. Here the way is a .user.ini at the root, with the content of the ini block above. PHP rereads that file every 5 minutes (user_ini.cache_ttl), so the change may take a little while to apply.

On shared hosting, the control panel usually has a PHP version and options selector that does the same without editing any file. To know whether the change took effect, Prestashop’s “Upload quota” shows the new value.

No upload: send the folder

The 2015 post also pointed out that modules and themes can be installed without going through the upload: unzip on your computer and send the folder over FTP to modules/ or themes/. The module then shows up in the back office catalog to be installed.

Two precautions I would add:

  • The right folder is the inner one. Many .zip files contain a folder that contains another folder. What goes into modules/ is the one with the module’s files directly inside it.
  • The folder name is the module name. Prestashop expects modules/mymodule/ to have a mymodule.php file. A renamed folder, such as mymodule-v2, makes the module not show up.

The 2015 tip of copying the .zip to /modules/themeinstallator/import/ applied to the theme installer of versions 1.4 and 1.5, which doesn’t exist in current versions.

References

Who writes this

Eduardo Lira

Software developer in Rio de Janeiro. I started this blog in 2012, in technical support at a hosting company, writing down the fixes for the problems that came up every day. Today I work at Sofis Tecnologia, on critical healthcare systems and SQL Server database migrations.

Found a mistake in this post?

A command that no longer works, a broken link, wrong information: tell me what you saw. The message goes only to the author and is not shown on the site.