php error when download files

本文讨论了如何通过调整ob_start函数的参数来优化PHP程序的内存使用,并解释了session_start及date_default_timezone_set函数对文件下载过程的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Just remove ob_start and session_star,and the program will be working.
1)ob_start("ob_gzhandler", 4096);// that is failed because the buffer size less than the file size.
2) ob_start("ob_gzhandler", 409600);// that is success because the buffer size more big than the file size.
3)ob_start("ob_gzhandler");// that is success because the buffer size is not limited.
We should not add ob_start here,because if download big file ,it will cost many memory buffer of server.

If we use the two php functions which are session_start and date_default_timezone_set ,our downloading process will be failed,if we only use any one of them,our downloading process will be success,it is very strange.
--- - hosts: all remote_user: root gather_facts: no tasks: - name: backup gy shell: cd /data1/htdocs/wd/download/helper && zip -r assist_`date +"%Y%m%d"`.zip assist when: type == 'gy' - name: backup jd shell: cd /data1/htdocs/wd/download/jd/helper && zip -r assist_`date +"%Y%m%d"`.zip assist when: type == 'jd' - name: backup dk shell: cd /data1/htdocs/wd/download/dk/helper && zip -r assist_`date +"%Y%m%d"`.zip assist when: type == 'dk' - name: backup wdhw shell: cd /data1/htdocs/wdhw/help/helper && zip -r assist_`date +"%Y%m%d"`.zip assist when: type == 'wdhw' - name: update gy unarchive: copy=yes src=files/assist_gy.zip dest=/data1/htdocs/wd/download/helper/ owner=nobody group=nobody mode=0777 when: type == 'gy' - name: update jd unarchive: copy=yes src=files/assist_jd.zip dest=/data1/htdocs/wd/download/jd/helper/ owner=nobody group=nobody mode=0777 when: type == 'jd' - name: update dk unarchive: copy=yes src=files/assist_dk.zip dest=/data1/htdocs/wd/download/dk/helper/ owner=nobody group=nobody mode=0777 when: type == 'dk' - name: update wdhw unarchive: copy=yes src=files/assist_wdhw.zip dest=/data1/htdocs/wdhw/help/helper/ owner=root group=root mode=0777 when: type == 'wdhw' - name: backup aikf_gc shell: cd /data1/htdocs/wd/download/aikf_help/gc && zip -r assist_`date +"%Y%m%d"`.zip assist when: type == 'aikf' - name: backup aikf_jd shell: cd /data1/htdocs/wd/download/aikf_help/jd && zip -r assist_`date +"%Y%m%d"`.zip assist when: type == 'aikf' - name: update aikf_gc unarchive: copy=yes src=files/assist_gy.zip dest=/data1/htdocs/wd/download/aikf_help/gc owner=nobody group=nobody mode=0777 when: type == 'aikf' - name: update aikf_jd unarchive: copy=yes src=files/assist_jd.zip dest=/data1/htdocs/wd/download/aikf_help/jd owner=nobody group=nobody mode=0777 when: type == 'aikf' # - name: backup aikf gc # shell: mv /data1/htdocs/wd/download/aikf_help/gc/assist /data1/htdocs/wd/download/aikf_help/gc_$(date +"%Y%m%d%H%M") # when: type == 'aikf' # # - name: backup aikf jd # shell: mv /data1/htdocs/wd/download/aikf_help/jd/assist /data1/htdocs/wd/download/aikf_help/jd_$(date +"%Y%m%d%H%M") # when: type == 'aikf' # # # - name: sync helper to aikf_help/gc # shell: cp -rf /data1/htdocs/wd/download/helper/assist /data1/htdocs/wd/download/aikf_help/gc/ # when: type == 'aikf' # # - name: sync jd to aikf_help/jd # shell: cp -rf /data1/htdocs/wd/download/jd/helper/assist /data1/htdocs/wd/download/aikf_help/jd/ # when: type == 'aikf' - name: patch background-color in basic.css (shell) shell: | sed -i '8i\ background-color:black;' /data1/htdocs/wd/download/aikf_help/gc/assist/basic.css when: type == 'aikf' - name: patch asktao.htm table style with shell shell: | sed -i '39s/height:100%/height:100%;background-color:black/' /data1/htdocs/wd/download/aikf_help/gc/assist/asktao.htm when: type == 'aikf' - name: patch background-color in basic.css (shell) shell: | sed -i '8i\ background-color:black;' /data1/htdocs/wd/download/aikf_help/jd/assist/basic.css when: type == 'aikf' - name: patch asktao.htm table style with shell shell: | sed -i '39s/height:100%/height:100%;background-color:black/' /data1/htdocs/wd/download/aikf_help/jd/assist/asktao.htm when: type == 'aikf' 执行报错原因 ----------------- 18:04:05 fatal: [helper_10.14.108.174]: FAILED! => {"changed": false, "msg": "Failed to find handler for \"/root/.ansible/tmp/ansible-tmp-1754906644.7111166-484-141141410877562/source\". Make sure the required command to extract the file is installed.\nCommand \"/usr/bin/unzip\" could not handle archive: End-of-central-directory signature not found. Either this file is not\n a zipfile, or it constitutes one disk of a multi-part archive. In the\n latter case the central directory and zipfile comment will be found on\n the last disk(s) of this archive.\nnote: /root/.ansible/tmp/ansible-tmp-1754906644.7111166-484-141141410877562/source may be a plain executable, not an archive\nunzip: cannot find zipfile directory in one of /root/.ansible/tmp/ansible-tmp-1754906644.7111166-484-141141410877562/source or\n /root/.ansible/tmp/ansible-tmp-1754906644.7111166-484-141141410877562/source.zip, and cannot find /root/.ansible/tmp/ansible-tmp-1754906644.7111166-484-141141410877562/source.ZIP, period.\n\nCommand \"/bin/gtar\" could not handle archive: Unable to list files in the archive: /bin/gtar: This does not look like a tar archive\n/bin/gtar: Skipping to next header\n/bin/gtar: Exiting with failure status due to previous errors\n\nCommand \"/bin/gtar\" could not handle archive: Unable to list files in the archive: xz: (stdin): File format not recognized\n/bin/gtar: Child returned status 1\n/bin/gtar: Error is not recoverable: exiting now\n\nCommand \"/bin/gtar\" could not handle archive: Unable to list files in the archive: tar (child): zstd: Cannot exec: No such file or directory\ntar (child): Error is not recoverable: exiting now\n/bin/gtar: Child returned status 2\n/bin/gtar: Error is not recoverable: exiting now\n\nCommand \"/bin/gtar\" could not handle archive: Unable to list files in the archive: gzip: stdin has more than one entry--rest ignored\n/bin/gtar: Child returned status 2\n/bin/gtar: Error is not recoverable: exiting now\n\nCommand \"/bin/gtar\" could not handle archive: Unable to list files in the archive: bzip2: (stdin) is not a bzip2 file.\n/bin/gtar: Child returned status 2\n/bin/gtar: Error is not recoverable: exiting now\n"}
最新发布
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值