I am generating a text file on server. I want this file to be able to get downloaded by clients accessing the site. How can I do this ?

Hey that was great...I tried it, I got the file download doalog. But when I download it, there is no extension to the file !! why is it happening???
Have a look at my code

Response.AppendHeader("content-disposition", "attachment; filename=" + "D:/telephone_management/AMS/files/" & fileName & " Upload.txt")
        Response.ContentType = "text/plain"
        'Response.WriteFile("D:/telephone_management/AMS/files/" & fileName & " Upload.txt")
        Response.WriteFile(fileName)
        Response.End()

the variable fileName contains today's date in dd-mm-yyyy format. My file name scheme is like..<date> Upload.txt. When file is downloaded, it is downloaded without Upload.txt part...why ???????????

Ok, above post had some wrong code...here is the code again

Response.AppendHeader("content-disposition", "attachment; filename=" + "D:/telephone_management/AMS/files/" & fileName & " Upload.txt")        Response.ContentType = "text/plain"        'Response.WriteFile("D:/telephone_management/AMS/files/" & fileName & " Upload.txt")        Response.WriteFile(fileName)        Response.End()Response.AppendHeader("content-disposition", "attachment; filename=" + "D:/telephone_management/AMS/files/" & fileName & " Upload.txt")
        Response.ContentType = "text/plain"
        Response.WriteFile("D:/telephone_management/AMS/files/" & fileName & " Upload.txt")
        Response.End()

the variable fileName contains today's date in dd-mm-yyyy format. My file name scheme is like..<date> Upload.txt. When file is downloaded, it is downloaded without Upload.txt part...why ???????????

I must be tripping...sorry again for the mess...here is the code

Response.AppendHeader("content-disposition", "attachment; filename=" + "D:/telephone_management/AMS/files/" & fileName & " Upload.txt")        Response.ContentType = "text/plain"        Response.WriteFile("D:/telephone_management/AMS/files/" & fileName & " Upload.txt")                Response.End()

Im not sure. Could it be the space? Try change the " " with "_"

Edited 5 Years Ago by ivatanako: n/a

Your thoughts and mine are matching...I tried just the same, just right now. Now my file name is <date>_Upload.txt ..but nothing's happening !! It is being downloaded as <date> only. No extension. I even tried

fileName = fileName + "_Upload.txt"
Response.WriteFile("D:/telephone_management/AMS/files/" & fileName)

Still nothing !!

Hey, this is really weird !!! I was testing this all on Mozilla. I tried the same on IE..voila !! Getting downloaded corectly. But I would want that to work correctly on Mozilla too. Any suggestions ???

Got it....

Response.AppendHeader("content-disposition", "attachment; filename=" + "D:/telephone_management/AMS/files/" & fileName & " Upload.txt")

in this line of code I did not write "_Upload.txt". Now everything's working fine. Thanks for your help !! :)

This question has already been answered. Start a new discussion instead.