服务器端阿帕奇Q
我有一个包含 sstv(慢速扫描电视)jpg 图像的页面,其中 12 个在表格中..它们随着火腿操作员发送 sstv 而变化..我的问题..我如何设置名为 1.jpg - 12 的图像。 jpg 可以通过下载链接下载到 zip 文件中。单击下载链接时,压缩需要在服务器端进行。这可能吗? ……或者……如果无法完整压缩 12 张图片,我如何在每个单独的图片下添加下载链接?
感谢您的帮助...我尝试过 .htaccess 使图像本身可下载,但无法使其工作,当我这样做时,它破坏了整个页面,因为我使用 htaccess 为一组俱乐部提供密码保护网站会员...
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次有人单击下载链接时压缩文件可能会导致服务器端处理成本高昂。如果你仍然想这样做,我建议用 PHP 等编写一个动态脚本来处理它。
不过,我建议编写一个简短的 cron 脚本(如果您使用的是 Windows 机器,则为 Windows 计划任务)来定期将文件压缩到预定的文件名和位置。例如,一个简单的 cron 条目可能如下所示:
使用 crontab -e 编辑您的 crontab(或 sudo crontab -e 编辑根 crontab)。然后添加 downloadfile.zip 的链接以供人们下载。是的,它每 15 分钟生成一次(可以随意调整时间),而不是按需生成,但这通常可以更好地为您提供一致的服务器性能。
如果您绝对必须按需生成它,请查看 PHP 的 Zip 库 进行实际压缩的函数,以及类似 tempnam 允许您将文件保存到有保证的唯一临时文件名并将其服务器到您的客户端。
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:
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.