Jump to content

FieldtypeFile and WireUpload: keeping the original ZIP archive after upload and unzipping


theoretic
 Share

Recommended Posts

Hi everybody and thanks again for a great product!

It happened to me to develop a website with pages containig a FieldtypeFile input. Backend users can upload zip archives there, and that archives are auto-extracted immediately after upload (of course I checked the 'unpack zip files' in Input section of my FieldtypeFile input). But the original zip archive is auto-deleted after that, and it is not present in both backend and $page->files array. However I would prefer to keep both the original zip file and all files extracted from it. This may be very useful if we want to give users the possibility to download all files associated with a certian page as a single zip archive.

The quick analysis led me to /wire/core/WireUpload.php:saveUploadZip($zipFile). This function deals with uploaded zip archives. I modified it, and now all my zip uploads are not deleted after zip auto-extraction. I did it in a quick and dirty way but it could be done much better. E.g. a special config option "Keep uploaded archives after unzip" could be introduced. Can do it if the community will have some interest.

My WireUpload file is attached below.

WireUpload.php

  • Like 1
Link to comment
Share on other sites

This is an interesting tweak, and a new config option for it doesn't sound like a bad idea either. If you'd like to get such a feature into the core, I would suggest submitting this as a feature request via GitHub issues. Either way, thanks for sharing this!

(For the record, I've just moved this topic to the General Support section, as it's not strictly speaking related to modules.)

Link to comment
Share on other sites

@teppo, thanks for a nice feedback! Adding my idea to Github issues could be great. Would also add another suggestion. The "Keep uploaded archives after unzip" option could be context-dependent. E.g. it will be great to have possibility of setting it globally but to override this behaviour for certain templates.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...