Solved

downloading files from SQL Server

Posted on 2009-04-04
5
190 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
In this article I will describe the Detach & Attach 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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 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