I have placed some code on a page that forces a download. I have it working if I hard code the filename (as shown below), however in the live application I need to populate the filename from a database. Can anyne tell me what is the coreect syntax to correctly enter the variable filename into this code - I think I keep getting the ," and ) in the wrong place. <!-- Start of Force Download Code --> <% Response.Buffer=true On Error Resume Next 'Create a stream object Dim tfm_downloadStream Set tfm_downloadStream = Server.CreateObject("ADODB.Stream") tfm_downloadStream.Type = 1 tfm_downloadStream.Open tfm_downloadStream.LoadFromFile Server.Mappath("../secure_documents/DavidsPDF_2_1.pdf") If Err.number = 0 Then Response.Clear Response.ContentType = "application/octet-stream" Response.AddHeader "Content-Disposition", "attachment; filename=DavidsPDF_2_1.pdf" Response.AddHeader "Content-Transfer-Encoding","binary" Response.BinaryWrite tfm_downloadStream.Read tfm_downloadStream.Close Set tfm_downloadStream = Nothing Response.End() Else tfm_downloadStream.Close Set tfm_downloadStream = Nothing Response.Redirect("document_error.asp") End If %> <!-- End of Force Download Code --> The variable fielname code is (rsDocument.Fields.Item("DocumentFilename").Value) Many thanks.
prev_code.. MyFileName = rsDocument.Fields.Item("DocumentFilename").Value MyFileName = "("../secure_documents/" + MyFileName tfm_downloadStream.LoadFromFile Server.Mappath(MyFileName) next_code...