简体   繁体   中英

Download a zip file and save temporarily in client machine

I have a client code in JS(say zip visualizer) which takes zip files as input and gives a visualization(html output) all in the client machine ie no part of the zip file is uploaded to the server.

I have the server in PHP which provides the zip visualizer code plus does some more computation. Now what I have to do is, on submit of a form take some input parameters from the user and do some computation in the server and generate a zip file. Now I want this zip file to go to the client and then go through the zip visualizer code and generate the html output. And the user should not be asked to download the zip file.

Can this be done?

My porposed solution: Save the zip file on server and:

  • Either read it on server side and send the HTML output to the client side

  • Or send file path to the client side. Create a simple PHP script which reads the zip file and sends binary data to client (not as file). You can visualize this data using client side library.

I would personally prefer the server-side solution as it is easier and does not burden the client side. (zips can be quite large)

You can not download a file to the client without permission. If this was possible it would be a serious security issue.

I would recommend that you do your processing on the server side

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM