Displaying Save File Dialog in Asp.net web page

孤街浪徒 提交于 2019-12-02 10:33:03

问题


I have a ASP.net page which writes a file to the local disk.

I want to present the user a Save File dialog box and allow him to set the path to the folder.

I know code like below can be used;

Response.Clear();
Response.ContentType = "text/csv";
Response.AddHeader( "Content-Disposition", "attachment;filename=\"report.csv\"" );
// write your CSV data to Response.OutputStream here
Response.End();

But it fixes filepath.

I need to capture the filepath that the user selects. Is that possible in ASP.net?

Thanks.


回答1:


it does not work like that from a web page, you have to initiate the download suggestiong a target file name then the user can override your suggested file name and select any folder or filename he likes and your content will be saved in that location.

you do nothing with a local path which only makes sense on the client machine on the server side of ASP.NET application.




回答2:


I need to capture the filepath that the user selects. Is that possible

No. Your web server presents a file to the client, where the client has the option to save this file.

In what way would the path the client saves this file be interesting to the server?



来源:https://stackoverflow.com/questions/15926960/displaying-save-file-dialog-in-asp-net-web-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!