Andrew
Andrew

Reputation: 1

Display an image from a ZIP file without extracting it to the server (PHP)

On my site, admins can upload ZIP files that contain a set of JPGs. Users can then download the ZIPs. I also want users to be able to preview images from the ZIP file. But I don't want to extract the images into a temp dir on the server and delete them later.

Is there a way to do this? Perhaps with the img "data:" URI scheme?

Upvotes: 0

Views: 828

Answers (1)

Marc B
Marc B

Reputation: 360782

One way or another, people would have to download parts of that zip file, so you might as well do some server-side processing and generate thumbnails of the images ONCE. Then just serve up those thumbs repeatedly. Otherwise you're going to waste a lot of cpu time repeatedly extracting images, encoding them for data uris, and sending out those data uris.

Upvotes: 2

Related Questions