Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!---Images in a blob field in the database --->
- <cfset imageMgrObj = createObject("component","model.imagetestDAO") .init()/>
- <!--- Where the number 52 is could be a RC variable for ColdBox or FW/1 --->
- <cfset variables.q = imageMgrObj.Read(ID=52) />
- <cfset variables.myfile = q.largeimage />
- <cfswitch expression="#LCase(ListLast(q.nameimage, "."))#">
- <cfcase value="avi">
- <cfset variables.contentType = "video/x-msvideo" />
- </cfcase>
- <cfcase value="doc">
- <cfset variables.contentType = "application/msword" />
- </cfcase>
- <cfcase value="docx">
- <cfset variables.contentType = "application/msword" />
- </cfcase>
- <cfcase value="exe">
- <cfset variables.contentType = "application/octet-stream" />
- </cfcase>
- <cfcase value="gif">
- <cfset variables.contentType = "image/gif" />
- </cfcase>
- <cfcase value="jpg,jpeg">
- <cfset variables.contentType = "image/jpg" />
- </cfcase>
- <cfcase value="mp3">
- <cfset variables.contentType = "audio/mpeg" />
- </cfcase>
- <cfcase value="mov">
- <cfset variables.contentType = "video/quicktime" />
- </cfcase>
- <cfcase value="mpe,mpg,mpeg">
- <cfset variables.contentType = "video/mpeg" />
- </cfcase>
- <cfcase value="pdf">
- <cfset variables.contentType = "application/pdf" />
- </cfcase>
- <cfcase value="png">
- <cfset variables.contentType = "image/png" />
- </cfcase>
- <cfcase value="ppt">
- <cfset variables.contentType = "application/vnd.ms-powerpoint" />
- </cfcase>
- <cfcase value="wav">
- <cfset variables.contentType = "audio/x-wav" />
- </cfcase>
- <cfcase value="xls">
- <cfset variables.contentType = "application/vnd.ms-excel" />
- </cfcase>
- <cfcase value="zip">
- <cfset variables.contentType = "application/zip" />
- </cfcase>
- <cfdefaultcase>
- <cfset variables.contentType = "application/unknown" />
- </cfdefaultcase>
- </cfswitch>
- <cfheader name="Content-disposition" value="attachment;filename=test.#LCase(ListLast(q.nameimage, "."))#" />
- <cfcontent type="#variables.contentType#" variable="#variables.myfile#" />
Add Comment
Please, Sign In to add comment