Solved

downloading files from SQL Server

Posted on 2009-04-04
5
175 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
Comment Utility
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
Comment Utility
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
Comment Utility
@ 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
Comment Utility
Thank you for your quick response.
0
 
LVL 51

Expert Comment

by:Mark Wills
Comment Utility
Happy to help...
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

762 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

10 Experts available now in Live!

Get 1:1 Help Now