How do I download filefrom database

A

Ather Ali Shaikh

Hi All
I have a database field of type Image.
I uplaod the file by using simpl asp.net
now I want to download that file directly to to the client side. with
download it on the server side.
I also saved the FileName, ContentType and FileExtenion in the database.

How do I do that . Please help.

I search it on google, and other sites but all have similar examples that
the file download from a web directory.
I do not want to use it.

Regards
Ather Ali
 
S

Steve C. Orr [MVP, MCSD]

Create a new web form and delete all the HTML (except the top yellow line)
In your code behind set the Response.ContentType to the appropriate string
for your file type.
(If you're not sure you can look it up here:
http://www.utoronto.ca/webdocs/HTMLdocs/Book/Book-3ed/appb/mimetype.html)

Now output your data using Response.Write if it's a text file, or
Response.OutputStream.Write if it's binary.

You might also want to set the filename so an Open/Save dialog will appear
to the user consistently.
You can do that with a line of code such as this:
Response.AddHeader("Content-Disposition","attachment;filename=" +
myDataReader["File_Name"].ToString());

Here's an example with complete source code:
http://www.aspnetpro.com/features/2003/07/asp200307so_f/asp200307so_f.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top