Reputation: 10021
I have the following code that downloads a file to the client's machine and it works great. However, I also need to ask the user where they want to save the file before the download begins.
Is this something I do in the action method (someone in the below code) or is this an option the client has to set on his/her browser and independent of what my code does?
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ";");
response.TransmitFile(filePath + fileName);
response.Flush();
response.End();
Upvotes: 0
Views: 1493
Reputation: 117
As best I can tell, that is the responsibility/behavior of the browser. If you want more client side control, you would have to write a client side app to save off to a specific location, or (easier) have the end user configure their browser to ask where to save downloads to.
Upvotes: 1
Reputation: 100527
Yes, "this an option the client has to set on his/her browser and independent of what my code does".
Upvotes: 1