using ASP to zip up file for downloading?

Discussion in 'ASP General' started by Andrew, Jul 14, 2005.

  1. Andrew

    Andrew Guest

    I am running a windows 2000 sv with IIS. My asp script creates a text file
    with an activation generated and put into the text file, so that the text
    file can be inported into a software program tha I created. This take away
    the maunuly typing in the code.

    Is thier an easy way to use asp to zip of the file and then the user can
    download the file?

    My other question is, is there a way to create a function in asp that can
    run when IE closes. I want to delete the file that was created for the user
    when the user exits the page, so that they don't fill my hard drive.

    Thanks
    Andrew, Jul 14, 2005
    #1
    1. Advertising

  2. 1. Why do you have to zip a text file? Is it large? The person can
    download a text file just fine. If you are trying to get around the fact
    that many people wouldn't know to right click the link and do a "Save target
    as..." (or other for other browsers) and want to encourage the download,
    take a look here. http://www.aspfaq.com/show.asp?id=2161

    If you decide you still want to zip the file, look here.
    http://www.aspfaq.com/show.asp?id=2187

    As for your other question, no. The server doesn't know when someone closes
    his browser. Perhaps what you should do, should you decide not to zip the
    text file, is do:

    (Adapted from link above)
    <%
    Response.ContentType = "application/Andrew's Product Key" ' arbitrary
    fn = "productkey.txt"
    Response.AddHeader "Content-Disposition","attachment; filename=" & fn

    Set adoStream = CreateObject("ADODB.Stream")
    adoStream.Open
    adoStream.Type = 2 ''(text instead of binary)
    adoStream.WriteText "Your product key text"
    adoStream.Position = 0
    Response.Write adoStream.ReadText
    adoStream.Close
    Set adoStream = Nothing

    Response.End
    %>

    Ray at home

    "Andrew" <> wrote in message
    news:...
    >I am running a windows 2000 sv with IIS. My asp script creates a text file
    > with an activation generated and put into the text file, so that the text
    > file can be inported into a software program tha I created. This take away
    > the maunuly typing in the code.
    >
    > Is thier an easy way to use asp to zip of the file and then the user can
    > download the file?
    >
    > My other question is, is there a way to create a function in asp that can
    > run when IE closes. I want to delete the file that was created for the
    > user
    > when the user exits the page, so that they don't fill my hard drive.
    >
    > Thanks
    Ray Costanzo [MVP], Jul 14, 2005
    #2
    1. Advertising

  3. Andrew

    Andrew Guest

    I'd rather have the people download the file as is, but when you click the
    link, it just shows the contents of the file, instead of showing the download
    dialog.

    "Ray Costanzo [MVP]" wrote:

    > 1. Why do you have to zip a text file? Is it large? The person can
    > download a text file just fine. If you are trying to get around the fact
    > that many people wouldn't know to right click the link and do a "Save target
    > as..." (or other for other browsers) and want to encourage the download,
    > take a look here. http://www.aspfaq.com/show.asp?id=2161
    >
    > If you decide you still want to zip the file, look here.
    > http://www.aspfaq.com/show.asp?id=2187
    >
    > As for your other question, no. The server doesn't know when someone closes
    > his browser. Perhaps what you should do, should you decide not to zip the
    > text file, is do:
    >
    > (Adapted from link above)
    > <%
    > Response.ContentType = "application/Andrew's Product Key" ' arbitrary
    > fn = "productkey.txt"
    > Response.AddHeader "Content-Disposition","attachment; filename=" & fn
    >
    > Set adoStream = CreateObject("ADODB.Stream")
    > adoStream.Open
    > adoStream.Type = 2 ''(text instead of binary)
    > adoStream.WriteText "Your product key text"
    > adoStream.Position = 0
    > Response.Write adoStream.ReadText
    > adoStream.Close
    > Set adoStream = Nothing
    >
    > Response.End
    > %>
    >
    > Ray at home
    >
    > "Andrew" <> wrote in message
    > news:...
    > >I am running a windows 2000 sv with IIS. My asp script creates a text file
    > > with an activation generated and put into the text file, so that the text
    > > file can be inported into a software program tha I created. This take away
    > > the maunuly typing in the code.
    > >
    > > Is thier an easy way to use asp to zip of the file and then the user can
    > > download the file?
    > >
    > > My other question is, is there a way to create a function in asp that can
    > > run when IE closes. I want to delete the file that was created for the
    > > user
    > > when the user exits the page, so that they don't fill my hard drive.
    > >
    > > Thanks

    >
    >
    >
    Andrew, Jul 14, 2005
    #3
  4. Andrew

    Andrew Guest

    thanks that was just what I was needing... thanks again..


    "Ray Costanzo [MVP]" wrote:

    > 1. Why do you have to zip a text file? Is it large? The person can
    > download a text file just fine. If you are trying to get around the fact
    > that many people wouldn't know to right click the link and do a "Save target
    > as..." (or other for other browsers) and want to encourage the download,
    > take a look here. http://www.aspfaq.com/show.asp?id=2161
    >
    > If you decide you still want to zip the file, look here.
    > http://www.aspfaq.com/show.asp?id=2187
    >
    > As for your other question, no. The server doesn't know when someone closes
    > his browser. Perhaps what you should do, should you decide not to zip the
    > text file, is do:
    >
    > (Adapted from link above)
    > <%
    > Response.ContentType = "application/Andrew's Product Key" ' arbitrary
    > fn = "productkey.txt"
    > Response.AddHeader "Content-Disposition","attachment; filename=" & fn
    >
    > Set adoStream = CreateObject("ADODB.Stream")
    > adoStream.Open
    > adoStream.Type = 2 ''(text instead of binary)
    > adoStream.WriteText "Your product key text"
    > adoStream.Position = 0
    > Response.Write adoStream.ReadText
    > adoStream.Close
    > Set adoStream = Nothing
    >
    > Response.End
    > %>
    >
    > Ray at home
    >
    > "Andrew" <> wrote in message
    > news:...
    > >I am running a windows 2000 sv with IIS. My asp script creates a text file
    > > with an activation generated and put into the text file, so that the text
    > > file can be inported into a software program tha I created. This take away
    > > the maunuly typing in the code.
    > >
    > > Is thier an easy way to use asp to zip of the file and then the user can
    > > download the file?
    > >
    > > My other question is, is there a way to create a function in asp that can
    > > run when IE closes. I want to delete the file that was created for the
    > > user
    > > when the user exits the page, so that they don't fill my hard drive.
    > >
    > > Thanks

    >
    >
    >
    Andrew, Jul 14, 2005
    #4
  5. Andrew

    JitGanguly Guest

    Just rename the file extension to somethign not recognizable, then it will
    ask you to download.

    Something like myfile.abc

    "Andrew" wrote:

    > thanks that was just what I was needing... thanks again..
    >
    >
    > "Ray Costanzo [MVP]" wrote:
    >
    > > 1. Why do you have to zip a text file? Is it large? The person can
    > > download a text file just fine. If you are trying to get around the fact
    > > that many people wouldn't know to right click the link and do a "Save target
    > > as..." (or other for other browsers) and want to encourage the download,
    > > take a look here. http://www.aspfaq.com/show.asp?id=2161
    > >
    > > If you decide you still want to zip the file, look here.
    > > http://www.aspfaq.com/show.asp?id=2187
    > >
    > > As for your other question, no. The server doesn't know when someone closes
    > > his browser. Perhaps what you should do, should you decide not to zip the
    > > text file, is do:
    > >
    > > (Adapted from link above)
    > > <%
    > > Response.ContentType = "application/Andrew's Product Key" ' arbitrary
    > > fn = "productkey.txt"
    > > Response.AddHeader "Content-Disposition","attachment; filename=" & fn
    > >
    > > Set adoStream = CreateObject("ADODB.Stream")
    > > adoStream.Open
    > > adoStream.Type = 2 ''(text instead of binary)
    > > adoStream.WriteText "Your product key text"
    > > adoStream.Position = 0
    > > Response.Write adoStream.ReadText
    > > adoStream.Close
    > > Set adoStream = Nothing
    > >
    > > Response.End
    > > %>
    > >
    > > Ray at home
    > >
    > > "Andrew" <> wrote in message
    > > news:...
    > > >I am running a windows 2000 sv with IIS. My asp script creates a text file
    > > > with an activation generated and put into the text file, so that the text
    > > > file can be inported into a software program tha I created. This take away
    > > > the maunuly typing in the code.
    > > >
    > > > Is thier an easy way to use asp to zip of the file and then the user can
    > > > download the file?
    > > >
    > > > My other question is, is there a way to create a function in asp that can
    > > > run when IE closes. I want to delete the file that was created for the
    > > > user
    > > > when the user exits the page, so that they don't fill my hard drive.
    > > >
    > > > Thanks

    > >
    > >
    > >
    JitGanguly, Jul 14, 2005
    #5
  6. Depending on how technically savvy the end user is, this might not be a very
    wise option. If you can force a download prompt without renaming the file
    (like the article demonstrates), why not do that?




    > Just rename the file extension to somethign not recognizable, then it will
    > ask you to download.
    >
    > Something like myfile.abc
    Aaron Bertrand [SQL Server MVP], Jul 14, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bienwell
    Replies:
    4
    Views:
    3,609
    Steve C. Orr [MVP, MCSD]
    Jun 3, 2005
  2. Craven Birds

    Link for downloading a zip file?

    Craven Birds, Jul 22, 2004, in forum: HTML
    Replies:
    6
    Views:
    435
    Craven Birds
    Jul 22, 2004
  3. abcd
    Replies:
    7
    Views:
    508
    Edward Elliott
    May 1, 2006
  4. majj81
    Replies:
    0
    Views:
    327
    majj81
    May 31, 2006
  5. Chris Lambacher

    Re: Add file to zip, or replace file in zip

    Chris Lambacher, Jun 1, 2006, in forum: Python
    Replies:
    0
    Views:
    596
    Chris Lambacher
    Jun 1, 2006
Loading...

Share This Page