server side apache Q
i have a page with sstv (slow scan TV) jpg images, 12 of them in a table..they change as the ham operators send the sstv.. my question ..how can i set the images named 1.jpg - 12.jpg to be downloadable in a zip file via a download link ..the zipping would need to occur server side when the download link is clicked..is that possible? ...... or.. how can i add a download link under each individual image if the complete 12 zipped up isnt possible?
thanks for any help... i have tried .htaccess to make the images themselves downloadable and could not get it to work, it开发者_开发技巧 broke the complete page when i did i think because i use htaccess to password protect the site for a group of club members...
Zipping the files up every time someone clicks the download link would probably be costly in terms of server-side processing. If you still want to do it, I would suggest writing a dynamic script in something such as PHP to handle doing it.
However, what I would suggest is writing a short cron script (Windows Scheduled Task if you're on a Windows box) to periodically zip up the files to a predetermined filename and location. For example, a simple cron entry might look like:
15 * * * * zip /path/to/downloadfile.zip /path/to/zip/images >/dev/nul
Use crontab -e to edit your crontab (or sudo crontab -e to edit the root crontab). Then put a link to the downloadfile.zip to let people download it. Yes, it's generated every 15 minutes (feel free to tweak the timing) instead of on demand, but that's generally better to give you consistent server performance.
If you absolutely must have it generated on demand, look into, for example, PHP's Zip library of functions to do the actual compression, and something like tempnam to allow you to save the file to a guaranteed unique temporary filename and server it to your client.
精彩评论