#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Classic ASP - Need help with download text file


    Hi all,

    I am creating a text file, that once created is to be downloaded. I have the file being created and saved on the server, the problem I am having is getting the download/open dialog to work. The following is my current code and while this works to a point, the file the user receives is a text file containing html code along with the contents of the actual file.

    Any and all help is appreciated.

    Const adTypeBinary = 1
    dim strFileName
    strFileName = "test.txt"
    dim strFilePath
    strFilePath = "c:\extracts\" + strFileName

    dim objStream
    Set objStream = Server.CreateObject("ADODB.Stream")
    objStream.Open
    objStream.Type = adTypeBinary
    objStream.LoadFromFile strFilePath

    Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
    Response.Charset = "UTF-8"
    Response.ContentType = "image/jpeg"

    Response.BinaryWrite objStream.Read
    Response.Flush
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    download text file using asp code


    I found url to help u code in asp
    ====> adf.ly/I0X7O
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by faisalismail
    I found url to help u code in asp
    ====> adf.ly/I0X7O
    ....and the url might be???????
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Location
    Santa Clara, CA
    Posts
    10
    Rep Power
    0
    I also Provide this URL Same as

    adf.ly/I0X7O
  8. #5
  9. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,440
    Rep Power
    4539
    Enough already. Thread closed.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo