Creating and serving zipped files with php

前端 未结 4 1974
别跟我提以往
别跟我提以往 2020-12-19 14:34

I\'m trying to use the following code to create a zip file from a directory and serve it to the user via an http download:

 // write the file
file_put_conten         


        
4条回答
  •  感动是毒
    2020-12-19 15:03

    As suggested by karim79, I'll put my comment as an answer: what happens if you change the MIME type from application/octet-stream to application/zip?

    Also, I see you're using a command line zip program, but you don't check for success of the zip, and also don't check if the file exists before attempting to send it out to the end users browser. Try hard coding a file name, manually using zip to guarantee a properly formed zip file, and then see if your code will spit it to your browser properly.

提交回复
热议问题