Re: What is easiest way to save a file to a users / client computer

From: Patrice (nobody_at_nowhere.com)
Date: 09/28/04


Date: Tue, 28 Sep 2004 16:14:29 +0200

This is RFC1806.

IMO you can't use a full path. Just use the file name and let the user save
the file at the location HE wants...

Patrice

-- 
"DanB" <agentkc@kc.rr.com> a écrit dans le message de
news:uAnBkOWpEHA.644@tk2msftngp13.phx.gbl...
> Ken,
>
>     I never would have come up with this own my own.  Thanks for pointing
me
> in the right direction.
>     I have tried the code and it gets me a lot closer.
>
>     I can't get it to name the attachment correctly.  It is giving it the
> name of the webform (issue.aspx) and defaulting to save it in my download
> folder (my IE default).
>
>     I believe the key is in the Response.addHeader portion as shown in the
> snippet below:
>         Response.AddHeader  ("content-disposition", "attachment;
> filename=""" & _
> >        user_Complete_Path_name & """")
>
>     Is "Attachment; Filename ="  the correct parameter to set or is there
> some other that might work better.
>
>     Thanks for your help.
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@sympatico.ca> wrote in message
> news:e1C2ogPpEHA.3252@TK2MSFTNGP14.phx.gbl...
> > Hi Dan,
> >
> > You need to make sure the browser sees it as an attachment so it will
> > prompt the user. Here's some code. Let us know if it works for you?
> >
> > Ken
> > Microsoft MVP [ASP.NET]
> > Toronto
> >
> >    Private Sub Page_Load _
> >    (ByVal sender As System.Object, _
> >    ByVal e As System.EventArgs) _
> >    Handles MyBase.Load
> >        ' ************************************************
> >        ' Forces a prompted download of a text file
> >        ' rather than displaying the text in the browser
> >        ' Ken Cox - MVP [ASP.NET]
> >        ' September 27, 2004
> >        ' ************************************************
> >        ' Create a stringbuilder to hold the text to be sent
> >        Dim sb As New System.Text.StringBuilder
> >        ' Create a string variable to hold a line of text
> >        Dim strLine As String
> >        'Give the file a name
> >        Dim filename As String = "mytext.txt"
> >        ' Get the text file using a stream reader
> >        Dim sr As System.IO.StreamReader = _
> >          New System.IO.StreamReader(Server.MapPath(filename))
> >        ' Loop through the text file, line by line
> >        Do
> >            ' Read a line of text into the string variable
> >            strLine = sr.ReadLine()
> >            ' Add the text content to the stringbuilder
> >            sb.Append(strLine)
> >            ' Do this while there's still text
> >        Loop Until strLine Is Nothing
> >        ' Close the stream reader
> >        sr.Close()
> >
> >        'Set the appropriate ContentType.
> >        Response.ContentType = "text/plain"
> >        ' Add a header telling the browser
> >        ' to expect an attachment and give it the
> >        ' name of the attachment
> >        Response.AddHeader _
> >        ("content-disposition", "attachment; filename=""" & _
> >        filename & """")
> >        'Write the file's content from the stringbuilder
> >        ' directly to the HTTP output stream.
> >        Response.Write(sb.ToString)
> >        Response.End()
> >    End Sub
> >
> >
> > "DanB" <agentkc@kc.rr.com> wrote in message
> > news:%23EA1DOOpEHA.3068@TK2MSFTNGP15.phx.gbl...
> >> This is probably soooo simple but I can't seem to get it.
> >>
> >> I have a text file that I want users to download via a web page.
> >>
> >> I want the file to be saved to a default folder (or one that they
choose)
> >> on the users / client file system.
> >>
> >> I have toyed with a Self-Extracting zip file but the contents of my zip
> >> file changes each time it is downloaded so that invalidates the exe
file.
> >> Also the text file is so small it is a waste to zip it.
> >>
> >> The IE:Download behavior looks at the text file and displays in the
> >> browser.
> >>
> >> I've look at client-side scripting using the FileSystem object but I
> >> can't seem to get FSO to open the file on the server.  Does anyone know
> >> can FSO open a file or copy a file from the server to the client?
> >>
> >> Ftp is always a possibility but how do I get it saved to the client
after
> >> it is downloaded?
> >>
> >> This should be simple.  What direction should I head here?
> >>
> >>
> >>
> >>
> >>
> >>
> >
>
>


Relevant Pages

  • Re: I cant find a SETUP.EXE in the SQL Plus Client ??
    ... someone else's server for testing some SELECT statements I'm writing for them. ... I just want a free client because I don't own the Oracle license. ... How do I get a free Oracle client installed, if possible, so I can test some SQL statements. ... There is no documentation with that download. ...
    (comp.databases.oracle.tools)
  • Re: Bug with Inbox app and POP3 account
    ... I have an identical problem with my 4150 - everything is set to "work" ... > when there are messages in the mailbox on the server. ... It seems that when the client sends a ... Messages download with no errors. ...
    (microsoft.public.pocketpc.phone_edition)
  • Re: Bug with Inbox app and POP3 account
    ... I have an identical problem with my 4150 - everything is set to "work" ... > when there are messages in the mailbox on the server. ... It seems that when the client sends a ... Messages download with no errors. ...
    (microsoft.public.pocketpc)
  • Re: I cant find a SETUP.EXE in the SQL Plus Client ??
    ... someone else's server for testing some SELECT statements I'm writing ... and I downloaded the "SQL Plus Instant Client". ... How do I get a free Oracle ... There is no documentation with that download. ...
    (comp.databases.oracle.tools)
  • Re: I cant find a SETUP.EXE in the SQL Plus Client ??
    ... else's server for testing some SELECT statements I'm writing for them. ... I just want a free client because I don't own the Oracle license. ... How do I get a free Oracle client installed, if possible, so I can test some SQL statements. ... There is no documentation with that download. ...
    (comp.databases.oracle.tools)