How can i convert html form data in ZIP file ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How can i convert html form data in ZIP file ??

I want to output zip file when i click on form submit button using html and php !

23rd Jun 2019, 11:12 AM
Rama Bariya
Rama Bariya - avatar
2 Answers
+ 3
Thank you
23rd Jun 2019, 1:49 PM
Rama Bariya
Rama Bariya - avatar
+ 1
I had some trouble understanding the question but hopefully some of these cases help. Do you want this to be your use case? 1. Submit a form. 2. Download zip file to browser 3. Open zip file to find .json file. 4. Extract .json file. 5. Open .json file to find all the inputs and values from the submitted form If yes, ZipStream or ZipArchive can help. ZipStream(https://github.com/maennchen/ZipStream-PHP) can help if you don't want to write the file to disk on the server. ZipArchive(https://www.php.net/manual/en/class.ziparchive.php) might be better if you're fairly new to web development but it appears to require writing a temporary file on the server before responding with the file to download. Writing JSON in PHP is likely a lot easier for you with built-in functions like json_encode(https://www.php.net/manual/en/function.json-encode.php). If, on the other hand, you want to download a static zip file(not dynamically written) on your server, https://stackoverflow.com/questions/7470846/send-zip-file-to-browser-force-direct-download should help. This might be the case if the form inputs determine which zip file to download. If these cases don't help, please give more context. - Why is zip format needed instead of a simpler file format? - If the zip is related to the inputs on the form, how should the information collected on the form affect the kind of zip that gets downloaded?
23rd Jun 2019, 1:32 PM
Josh Greig
Josh Greig - avatar