English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to create a txt on the client side (I do not want to save it on the server if this is possible), then I want to upload it to the client and from my webpage. How would I go about doing this? I only find things on how to upload to the server on the net. However, I want to upload to the client.

2007-03-17 16:09:29 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

But I want to do it via a button on the asp page.

2007-03-17 16:51:17 · update #1

How would I do that?

2007-03-17 17:14:41 · update #2

2 answers

That would be called "downloading" and would be done by giving the user a link to the file on the server.

Edit: Then make the button redirect to the file instead of using a link. The easiest way would probably just be to use JavaScript... write a function that redirects to the file you want them to download, and have the button onClick event invoke the function.

2007-03-17 16:23:33 · answer #1 · answered by Rex M 6 · 0 0

I think what you want to do is stream a binary to the client.

What I describe here, you'd put in the Button_Click event and would cause a pop-up to appear on the client screen that gives the option to save, open or cancel. Bear in mind - there is no web code that allows you to just write to a client computer - that's called a Trojan Horse (yeah, yeah -some people are stupid and let you do it, but you shouldn't write you code to assume that).

But, this code should get you moving along the path I think you want to take.

Use the Response object, just like you'd do Response.Write.
However, instead do this:
BinaryStream myStream = SomeFunctionToGetStream
Response.BufferOutput = true
Response.ClearHeaders()
Response.ClearContent()
Response.Write("content-disposition","inline;filename=MyFile.txt");
Response.AddHeader("content-length", myStream.length)
Response.BinaryWrite(myStream);
Response.Flush

I'm probably missing a command or two since I'm doing this off my head - I don't write this specific type of code much - instead I just wrap it up in a class. Anyhoo - seach on BinaryWrite and those other commands and you should be able to find a real example.

2007-03-17 17:34:03 · answer #2 · answered by vbslinger 2 · 0 0

fedest.com, questions and answers