cfzip 有什么方法可以暂停页面处理,直到 zip 创建完成?

cfzip any way to pause page processing until the zip creating is complete?

我有一些代码可以创建一些图像的 zip 文件,然后在该代码之后立即尝试下载该文件。当 zip 文件很小时,此方法工作正常,但当它较大时,它会尝试在实际完成创建之前下载文件。

所以像这样

<CFZIP code here>

<cfset TheFileName = "#ReReplace(GetImage.ItemNum, " ", "-", "ALL")#.zip">

<cfheader name="Content-disposition" value="attachment;filename=#TheFileName#">
<cfcontent type="application/zip, application/x-zip, application/x-zip-compressed, application/octet-stream, application/x-compress, application/x-compressed, multipart/x-zip" file="#APPLICATION.ProductImageDirectory#\full-brands\#TheFileName#">

您的代码有几个问题。

Firstly, your mime-type list should be separated by a semicolon ; instead of a comma , as documented here.

所以不用这个

<cfcontent type="application/zip, application/x-zip, application/x-zip-compressed, application/octet-stream, application/x-compress, application/x-compressed, multipart/x-zip" file="#APPLICATION.ProductImageDirectory#\full-brands\#TheFileName#">

你应该改成这个

<cfcontent type="application/zip; application/x-zip; application/x-zip-compressed; application/octet-stream; application/x-compress; application/x-compressed; multipart/x-zip" file="#APPLICATION.ProductImageDirectory#\full-brands\#TheFileName#">

Secondly, while this might not be an issue, but it seems like you have some serious mime-type overkill going on in your <cfcontent> tag. Since I don't really know, I can't really say that you should remove any of them. However, I'm not sure if any in your list might have a conflict with others? I've personally only used just application/x-zip-compressed and it seems to work just fine. So the bottom line is perhaps tweak and experiment to find what works best.

祝你好运,希望这对你有所帮助。

我发现了问题。我正在将 zip 文件写入一个目录,然后尝试从另一个目录下载它。奇怪的是,我本以为会收到 404 not found 消息,但它基本上只是给我发送了一个空的 zip 文件。无论哪种方式,问题都解决了。