initiating a file download via a Button

  • Thread starter Thread starter matt
  • Start date Start date
M

matt

hello,

how does one inititate the dowloading of a file via a button click? for
example, i have a file sitting on the webserver; when the user clicks
on a button, i'd like them to see their web browser's "save this file
to the file system" dialogue and have them download it.

im not even sure if this would be server-side or client-side. either
works for me.

any tips?

thanks!
matt
 
....that didnt work for me for some reason.

no sweat tho, i found another way:

//send file to user
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("content-disposition", "attachment; filename=" +
fileName);
Response.Flush();
Response.WriteFile(fileAbPath);
Response.End();

....this has an added advantage of allowing me to use a dynamically
generated filename. cool.


thanks,
matt
 

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

Back
Top