Reputation: 77
I have some code that creates a zip file of some image and then right after that code it tries to download the file. This works fine when the zip file is very small but when it is larger it tries to download the file before it is actually completed being created.
So something like this
<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#">
Upvotes: 2
Views: 150
Reputation: 77
I found the issue. I was writing the zip file to one directory and then trying to download it from another. The strange thing was I would have expected a 404 not found message but it basically just delivered me an empty zip file anyway. Either way, problem solved.
Upvotes: -1
Reputation: 1074
A couple of issues with your code.
Firstly, your mime-type list should be separated by a semicolon
;
instead of a comma,
as documented here.
So instead of this
<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#">
Your should change it to this
<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 justapplication/x-zip-compressed
and it seems to work just fine. So the bottom line is perhaps tweak and experiment to find what works best.
Good luck and hope this helps.
Upvotes: 0