Prestashop: Cannot upload a theme with zip folder which includes the theme folder in the zip

Created on 6 Aug 2019  路  10Comments  路  Source: PrestaShop/PrestaShop

Describe the bug
When we try to upload a theme with a zip folder which includes the theme folder in the zip, an alert is displayed
PS1.7.6.0
image
PS1.7.5
image

To Reproduce
Steps to reproduce the behavior:

  1. Create a theme
  2. Create a zip for this theme, make sure that the theme folder in the zip
  3. Try to import it into PS.
  4. See error

childtheme-example.zip

Additional information
PrestaShop version: 1.7.6 / 1.7.5
PHP version: 7.0

1.7.5.1 1.7.6.0 BO Bug Design Minor PR available Theme & logo To Do

All 10 comments

Regarding the issue where a zip file is rejected already on the client side. The issue in my case (Windows 10 / Chrome 76 / PrestaShop 1.7.6.1) was that the dropzone only accepts application/zip, but Chrome identified the file as application/x-zip-compressed. Modifying the acceptedFiles variable (using debugger) to "application/zip,application/x-zip-compressed" made the dropzone to accept my zip and child theme was successfully uploaded and available in back office.

@jkivelae Thanks
Could your confirm that the file to modify is modules\ps_themecusto\views\js\controllers\advanced\back.js ? (line ~80)
According to checkfiletype.com, my file is application/x-zip, so I included that, but it does not work better. I cleared the cache. Did you do something more ?

I didn't go deeply but the problem is the ZIP file.
I had same problem, I extracted and zip again all files of theme with 7-zip on Windows environment and operation ended successfully.
Note: I tried also on Mac environment (I zip again all files of theme with default option of Apple) but error persist.

Change the core is not a best practices

@pierreloicq I actually modified the variable on-the-fly in the Chrome debugger.

I checked the file you mentioned (modules\ps_themecusto\views\js\controllers\advanced\back.js ~line 80) and I think it should work.

Adding ",application/x-zip-compressed" seemed to work for my zip file.

...
Dropzone.options.importDropzone = {
  acceptedFiles: 'application/zip,application/x-zip-compressed',
  maxFiles: 1,
...

After the edit, clearing the PrestaShop cache and a browser refresh you should see the affect when inspecting the html-tree of the dropzone. Something like this:

<form action="#" class="dropzone dz-clickable" id="importDropzone">
  ...
  <input type="file" class="dz-hidden-input" accept="application/zip,application/x-zip-compressed" style="visibility: hidden; position: absolute; top: 0px; left: 0px; height: 0px; width: 0px;">
</form>

_Note for others: That input element will be added in the JavaScript so it is not part of the raw/original source code - should be visible in Chrome Developer Tools._

ok, it didn't work because the cache was strong, now it's ok
Thank you :-)

Hi @jkivelae,

Would you be willing to make a pull request on GitHub with your code suggestion?
https://github.com/PrestaShop/ps_themecusto
Thank you!

@pierreloicq Thanks for the PR!

note that the pull request is merged and should be available in a recent release (https://github.com/PrestaShop/ps_themecusto/releases/tag/v1.2.0)
did someone tested if this is issue is solved?

The issue still persists on 1.2.0

Was this page helpful?
0 / 5 - 0 ratings