473,587 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2566
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**@discussio ns.microsoft.co m> wrote in message
news:12******** *************** ***********@mic rosoft.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1715
by: Michael Rogers | last post by:
I dunno how save a file locally! How can I copy a file (http://foo.com/foo.zip) to my local server (http://mydomain.com/temp/foo.zip)? I saw a sample in MS Quick Start but I can't manipulate it to work with for example zip files. WebRequest req = WebRequest.Create(txbFile.Text); try {
8
2394
by: kieran | last post by:
Hi, I want to download an image from the web and save it locally. I have spent all day messing about with this and am still no where. We have a firewall so i use the below code. I know it works down to the line as i also use this code to download an xml file from the net. I have been messing around with all sorts of ways to stream the...
4
4498
by: sunilj20 | last post by:
Hello, I have a requirement wherein, a user clicks on a file name in an ASP.NET web application, and the file should automatically be downloaded (Without showing the "Open", "Save As") in the local machine at a pre defined path (path defined in the registry), and launch the file in its associated application. I think this can be done...
2
6351
by: standish22 | last post by:
want to open a word document stored in my database. What I do is save the document locally, and then open a new winform that has the WebBrowser Control on it and navigate to that new file. This allows the user to manipulate the file and save it. When they close the WebBrowser, if the contents has changed I save it back to the db, and...
0
1275
by: Matt Schwartz | last post by:
I have a ASP.NET web application written using VB.NET. I have a data grid, that is sent to the browser as an excel document using the following code Private Sub CreateXLS(ByVal xdatagrid As DataGrid) Response.Clear() Response.AddHeader("content-disposition", "filename=New_Report.xls") Response.Charset = ""...
4
1526
by: teeBull | last post by:
Hi all, We'd like to take advantage of code we already have for transforming XML into HTML (using XSLT) for our users to save the HTML as an MS Word document locally. I've dug around and found the following code to include in the code behind: Response.ContentType = "application/vnd.ms-word" Response.AddHeader("Content-Disposition",...
2
5909
by: Adam | last post by:
On one site I'm working on I occasionally get an error where instead of executing the PHP file as per normal, the browser sees the page as a file (therefore opens up a execute/save pop-up). All these pages work fine locally on my Apache/WinXP but produces these errors on the remote server (Linux/on Apache/1.3.34). Where do I start...
6
24246
by: greg_e | last post by:
Is there a way to create a form in a local html file where the contents of the form are written to a local file when a 'save' button is selected? It would be nice if it was as easy as changing "somesite.com" to "file:///C:/whatever" and "post" to "save"... in the following form: <form action = "somesite.com" method="post"> <p<textarea...
5
9865
by: Arch Stanton | last post by:
I have a set of ASPX pages that work fine on my home computer (Vista), and on a server at work (XP). I just got a new laptop at work (XP) and these same files don't work on it. I installed IIS and dot.net on my new computer, but every time I try to access the ASPX pages locally (using http://localhost/main.aspx in the browser address bar), the...
0
7852
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.