Solved

downloading files from SQL Server

Posted on 2009-04-04
5
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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