Adding array of file to a zip file? (php server side action)

Hello,

I’m stuck at trying to add an array of files (images) to a single zip file on the server side (PHP) - all I get is the first file from either a repeat action or its original database query:

If I add the Files to Zip step into the repeat, I get one new zip file per result, rather than adding to the existing zip file.

I’ll appreciate any and all guidance.

Hi.
Passing an array of file paths should work. Has been some time since I last used it.
The binding looks weird in the screenshot shared.
Maybe try passing a simple array containing just path of files.

Hi @sid,

How would you suggest building the array? Considering the output of the ‘user_images’ query needs modifying to match the path of the file (it needs appending ‘/user_data/’) - the input is accepted by the Files to Zip module, but obviously the database query is missing that appended data.

Thanks for your help.

To append data, you will have to swtich to custom query.
It should not be a diffcult task, unless you have conditional conditions.

Then using the flatten formatter, you should be able to extract and past an array of paths to files to Zip step.
Does that make sense?

Thanks @sid, that’s very valuable advice. I now have an array that returns the correct values:
{"test":["\/user_data\/EBDCE817-CA07-4B9A-A8BB-C16D28D4E4D1.jpg","\/user_data\/D5E72921-F486-48BF-A353-CA53EA837910.jpeg"]}
however, I get an incorrect path from the Files to Zip output, I believe it may be because of the added slashes, an issue I’ve already been stuck with here.

Interesting.
Assuming that the path stored in DB is something like /user_data/EBD...., try replacing the slashes in the custom query as well. Replace \ with /.

Although, this might cause an issue when switching between Linux/Windows environment.

It seems the added slashes are added after the output of the query, within Wappler’s Json. @patrick, @Teodor, would you have any suggestions? This seems to be a setting within json_encode.