php转换为zip并下载 [英] php convert to zip and download

查看:63
本文介绍了php转换为zip并下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将文件转换为zip并使其可供用户下载,此zip文件是在运行时创建的。

对于此即时通讯使用代码来自

http ://www.9lessons.info/2012/06/creating-zip-file-with-php.html?m = 1

工作正常,但是当创建的拉链尺寸很大时,即30 mb ,我无法下载,因为下载的filze大小只有1或2 kb

(而不是30 mb),虽然在服务器上创建的zip文件大约是30mb

什么可以问题

I want to convert files to zip and make it available for user to download, this zip files are created at runtime.
For this i m using code from
http://www.9lessons.info/2012/06/creating-zip-file-with-php.html?m=1
It works fine but when size of zip created is large ie 30 mb, i am unable to download as downloaded filze size is just 1 or 2 kb
(Instead of 30 mb),though zip file created on server is about 30mb
What could be problem

推荐答案

请使用: http:// php.net/manual/en/book.zip.php [ ^ ]。



直接在HTTP响应中提供ZIP文件(不存储文件和使用HTTL 锚点元素),指定HTTP标题''Content-type:application / zip'':

Please use: http://php.net/manual/en/book.zip.php[^].

To provide a ZIP file on the fly, directly in HTTP response (without storing a file and using HTTL anchor element), specify the HTTP header ''Content-type: application/zip'':
header('Content-type: application/zip');





另请参阅:

http://en.wikipedia.org/wiki/Media_type [ ^ ],

http:/ /www.iana.org/assignments/media-types [ ^ ]。



-SA


这篇关于php转换为zip并下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆