Solved

downloading files from SQL Server

Posted on 2009-04-04
5
182 Views
Last Modified: 2013-12-24
Using Coldfusion 8 on windows platform with SQL Server 2008 Express.
I have a table that's holds files converted to binary.
When it came time to download I used this:

<cfheader name="content-disposition" value="attachment; filename=#getFile.name#">
<cfcontent variable="#getfile.Contents#">

... Which did everything I needed it to do, invoked a save as dialog box or open file.
Worked perfectly... in Firefox.

I've read this has issues in IE and yep! sure does.

So how can I get my file(s) back??

I shifted to this for the sake of IE knowing I could check the browser and IF it's IE do this:

<cffile action="write"
      file="C:\temp\#getFile.name#"
      output="#getFile.Contents#">

Which works perfectly... if you're saving to the server and not allowing the user to save to their drives, which is what I need.

To that I ask for help!

TIA
0
Comment
Question by:ecpeel
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

by:duncancumming
ID: 24070546
Don't you need to use ToBase64() to convert it from Binary before doing cfcontent?
0
 
LVL 51

Accepted Solution

by:
Mark Wills earned 500 total points
ID: 24077261
Normally hold the attachments externally, but in SQL 2008 can also hold as filstream - how have you stored them in 2008 ?

as an external file, this normally works :

<cfheader name="Content-Disposition" value="attachment; filename=#GetFile.FileName#">         or might try:   value="inline;
<cfcontent type='application/unknown' file='#RootDirectory#\#GetFile.FileName#'>                        the application/unknown normally invokes the save as...
0
 

Author Comment

by:ecpeel
ID: 24077486
@ Mark wills:
I converted to binary and stored them in a column of  image datatype. This seems to be working well and when tested  using Firefox and the CFcontent it converts back without using ToBase64() (responding to duncancumming).
OK got it to work: seems 'application/unknown' did the trick, but for the sake of discussion i'm including my code below.
Many thanks!

<cfheader name="content-disposition" value="attachment; filename=#getFile.name#"> 
<cfcontent variable="#getfile.Contents#"> 
<cfcontent type='application/unknown' file='#getfile.Contents#'>   

Open in new window

0
 

Author Closing Comment

by:ecpeel
ID: 31566703
Thank you for your quick response.
0
 
LVL 51

Expert Comment

by:Mark Wills
ID: 24077600
Happy to help...
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now