开发者

cfcontent appending the wrong file extension on forced download of .EPS and .AI files

I've created a force download for a client's site recently and all works well with the usual suspects like .jpg, .png, .tif and even .pdf.

But, when I serve up an Adobe Illustrator file or an eps, the file gets an appended extension upon downloading.

I'm certain I know where the problem originates but I don't know how to work around it. In my code, my <cfcontent> tag assigns type="application/postscript" to the .eps and .ai file because those are the MIME types based on the list at W3shcools here: MIME Types

Is there some way to force a MIME type of, say type="application/开发者_JAVA百科ai" in a shared hosting environment? Or, is there a way for me to get a list of MIME type mappings with a tag or something so I can see if there is a more suitable MIME type available to me?

Here's my force download code:

<cfset FileDownload = #URL.file#>
<cfset exten = ListLast(FileDownload, ".")>
<cfswitch expression="#exten#">
  <cfcase value="ai"><cfset content_type = "application/postscript"></cfcase>
  <cfcase value="eps"><cfset content_type = "application/postscript"></cfcase>
  <cfcase value="pdf"><cfset content_type = "application/pdf"></cfcase>
  <cfcase value="jpg"><cfset content_type = "image/jpeg"></cfcase>
  <cfcase value="png"><cfset content_type = "image/png"></cfcase>
  <cfcase value="tif"><cfset content_type = "image/tiff"></cfcase>
  <cfdefaultcase><cfset content_type = "image/jpeg"></cfdefaultcase>
</cfswitch>
<cfheader name="content-disposition" value="attachment;filename=#FileDownload#">
<cfcontent type="#content_type#" file="#ExpandPath("./#folder#")#/#FileDownload#" deletefile="no">


Might try changing the content_type to application/octect-stream instead for the ai and eps extensions and let the browser figure out the program association on the client side. octet-stream can be used for any binary file type.


Did you try this:

<cfcase value="ai"><cfset content_type = "application/ai"></cfcase>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜