469,313 Members | 2,642 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

Save a file locally for ASP.net 2

Hi,
I would like to save a file locally (on the client computer) in an ASP.net
application.
It is like the server would return some data that the user can save to a
file on his local PC.
The ASP page has a text field to type in the file path directly and a
"Browse..." button, that shall display a "Save as..." dialog.
I tried with the FileUpload control, but this does not work, since I do not
want to upload an existing file, but I want to save a new file locally.
Any idea how this can be done?

Thanks and best regards, Matt
May 12 '06 #1
4 2381
im not sure you'd be able to to be honest (although I could be wrong). it
would be waay to much of a security risk.

the only way I can think of is generate the file on the server with the name
entered, stick it in a temporary directory unique to the session, and then
fire a download link, to prompt the user to download and open|save the file.

hth
"Matt" wrote:
Hi,
I would like to save a file locally (on the client computer) in an ASP.net
application.
It is like the server would return some data that the user can save to a
file on his local PC.
The ASP page has a text field to type in the file path directly and a
"Browse..." button, that shall display a "Save as..." dialog.
I tried with the FileUpload control, but this does not work, since I do not
want to upload an existing file, but I want to save a new file locally.
Any idea how this can be done?

Thanks and best regards, Matt

May 12 '06 #2
You can't do that, this would be a major security hole if a web page could
automatically save a page to a given location on the client hard drive.

You will have to stream out the file, and the user will be prompted with a
save dialog - and have to save that way, which is the usual manner of
downloading files.

"Matt" <ma**@discussions.microsoft.com> wrote in message
news:12**********************************@microsof t.com...
Hi,
I would like to save a file locally (on the client computer) in an ASP.net
application.
It is like the server would return some data that the user can save to a
file on his local PC.
The ASP page has a text field to type in the file path directly and a
"Browse..." button, that shall display a "Save as..." dialog.
I tried with the FileUpload control, but this does not work, since I do
not
want to upload an existing file, but I want to save a new file locally.
Any idea how this can be done?

Thanks and best regards, Matt

May 12 '06 #3
You can't save a file on the client computer from the server.

You can let the user download a file, as musosdev suggested.

You can create an ActiveX control or Java applet to put on the web page,
that runs on the client and saves a file. This of course requires that
the user accepts that the control is started.

Matt wrote:
Hi,
I would like to save a file locally (on the client computer) in an ASP.net
application.
It is like the server would return some data that the user can save to a
file on his local PC.
The ASP page has a text field to type in the file path directly and a
"Browse..." button, that shall display a "Save as..." dialog.
I tried with the FileUpload control, but this does not work, since I do not
want to upload an existing file, but I want to save a new file locally.
Any idea how this can be done?

Thanks and best regards, Matt

May 12 '06 #4
Thanks for all answers. This solved my problem.
Matt
May 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Michael Rogers | last post: by
8 posts views Thread by kieran | last post: by
4 posts views Thread by sunilj20 | last post: by
4 posts views Thread by teeBull | last post: by
2 posts views Thread by Adam | last post: by
6 posts views Thread by greg_e | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.