ok i have got code that can download a file BUT if i use a download manager it downloads the whole aspx file. The same things happens with PHP and is a big security flaw so i need to stop this. My download manager comes up by default unless i cancel it then it works with normal save file to download.
I cant have this as the download manager will download the aspx file i am using.
What this is doing with a download manager is downloading the url name instead of the given filename. so if the file name in the url is http..../download.aspx it will download that file.
Code:Dim fullpath As String Dim name As String Dim type As String = "" Dim ext As String Dim forceDownload As Boolean name = "revision3.doc" forceDownload = True ext = ".doc" fullpath = "f:\asp\" + name If Not IsDBNull(ext) Then ext = LCase(ext) End If Select Case ext Case ".htm", ".html" type = "text/HTML" Case ".txt" type = "text/plain" Case ".doc", ".rtf" type = "Application/msword" Case ".csv", ".xls" type = "Application/x-msexcel" Case Else type = "text/plain" End Select If (forceDownload) Then Response.AppendHeader("content-disposition", _ "attachment; filename=" + name) End If If type <> "" Then Response.ContentType = type End If Response.WriteFile(fullpath) Response.End() End Sub




Reply With Quote