send zip file to browser / force direct download

后端 未结 4 1321
感情败类
感情败类 2020-12-06 00:47

i created with php zip ( http://php.net/manual/de/book.zip.php ) a zip file

now i have to send it to the browser / force a download for it.

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 01:14

    You need to do it this way, otherwise your zip will be corrupted:

    $size = filesize($yourfile);
    header("Content-Length: \".$size.\"");
    

    So content-length header needs a real string, and filesize returns and integer.

提交回复
热议问题