Hello,

Thinks it would be a great feature if eg zip files could be uploaded, uncompressed on the server and the content checked for permitted file extensions of that content type so that the separate files are shown in multiple filefield fields.

Especially for picture albums, I think this could be a great feature so that you don't have to upload the pictures one by one.

CommentFileSizeAuthor
#10 imagefieldzip.zip887 bytesDimm

Comments

trogie’s picture

OK, I was looking into the filefield widget functions. And currently looking at the filefield_paths module how the filefield API works.

Does anybody think a filefield dependent extra module could 'easily' be implemented to do these things:
-add extra checkbox under the permitted file extensions in the content type filefield configuration settings to permit zip files of the above specified file extensions.
-extend the upload validation to allow these zip files
-add extra functionality to 'unzip' the zipfile and verify the individual files in the zipfile (file extensions, filesizes,...)
-update the filefields in the 'node_add' form to display the validated individual files

I would really like this feature for my next websites (especially for the picture albums) and can spend some time to implement it myself but a little extra help on how to start with it would be very welcome off course(filefield API documentation eg)!

trogie’s picture

First things are done already (checking for php zip extension, checkbox in the field configuration settings)

Now I'm trying to find out a way to validate a zip file after uploading a file but before the normal filefield file validation and others take over... any ideas?

twowheeler’s picture

You know, the Gallerix module already does this very well. The user can upload a zip file, and the server opens it and allows the user to enter a description for each file before adding them to a photo gallery. It is a great feature and would add a lot here. It might be possible to siphon some code out of the gallerix module, or at least get some ideas of how to do it.

trogie’s picture

Thanks. yes, there are a lot of modules who implement some kind of 'unzipping' but almost all of them are creating their own forms and so are not using any cck functionality. I prefer not to reinvent the hot water again... Having this feature for filefield would also enable all modules that depend on filefield...

trogie’s picture

ok, for filefield I can already upload zipfiles and uncompress it. With imagefield I have a problem that there is a validator set (filefield_validate_is_image) and that one returns an error off course for the zip file... No idea yet how I could solve this.

attiks’s picture

anybody has already some code to share / test?

Flying Drupalist’s picture

subscribe :)

Dimm’s picture

trogie’s picture

@attiks:

I don't have any code online yet. In the code I have currently I'm not actually unzipping (just looping over the zipfile and outputting some debug info). When I'm done with the unzipping I'll put the highly development code online. After that I think I'll need some help for pushing back the individual files information to the uploading client if there's javascript involved...

@dimm:

I know about the imagefield patch for zipfiles on D5, but I have always seen this functionality more general and as imagefield depends on filefield, it was my idea that filefield should have this feature. Imagine a content type that can have multiple pdf files attached (filefield) is not very different to a content type with multiple images (imagefield). A problem I forsee with imagefield is that the zipfile should get uncompressed and accepted before the filefield_file_is_image validation function gets called...

Dimm’s picture

StatusFileSize
new887 bytes

@ trogie:
I begin write code to upload zip to imagefield
May be it help you.

dopry’s picture

@trogie: I suggest you try doing your work in #process... It can be quite aggravating to debug, but the results could be promising since you can add all your files to the form at this point.. You may need to rebuild/override some validation logic... I should have drawn up a flow chart of the form processing when I implemented all of that originally.

quicksketch’s picture

Dimm linked to it above, but there's a matching issue in the ImageField queue that does the same thing: #251096: Upload multiple images at once (archive/php_zip support).

quicksketch’s picture

Status: Active » Closed (duplicate)

I'm marking this duplicate and moving #251096 to the FileField queue.