doujiang9887 2013-08-12 12:01
浏览 35
已采纳

PHP字符串自动下载zip

I have a php file which reads data from an user submitted form and puts it into two different strings. I want to put these strings in separate txt files and put them into a zip archive which would be downloaded by the user when he submits the form.

How can I do that? And is there a way to give each zip an unique name so there wouldn't be any possible conflicts?

  • 写回答

1条回答 默认 最新

  • doushan3511 2013-08-12 12:22
    关注

    Create two text files with fwrite and then use the create_zip function described here http://davidwalsh.name/create-zip-php like this:

    $files_to_zip = array(
    'textFileA.txt',
    'textFileB.txt'
    );
    $zip_name = uniqid().'.zip';
    $result = create_zip($files_to_zip, $zip_name);
    

    And then use a HTTP header to download the ZIP file created.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?