Forcing a file downoad when files are on different

Results 1 to 2 of 2

Thread: Forcing a file downoad when files are on different

  1. #1
    Join Date
    Dec 1969

    Default Forcing a file downoad when files are on different

    Hi,<BR>I have a number of documents where I need to force a file download. This in no problem for files that are held locally on the web server but there are a number of files that exist on various other Drives <BR>e.g. G:Engagement ManagementEngagement Template DocsTerms_Of_Engagement template.doc<BR>or<BR><BR><BR>the following code works for files held locally such as template.doc how can I extend it to take in various file paths or will I need a number of download.asp files???<BR>&#060;%<BR>Response.Buffer = true<BR>strFileName=Request.Querystring ("file") <BR>strFilePath=server.mappath("/fiscintranet_dev/Dat/PPI Stage/"&strFilename)<BR>Response.Write (strFilePath)<BR>set fso=createobject("scripting.filesystemobject")<BR> set f=fso.getfile(strFilePath)<BR>strFileSize = f.size<BR>set f=nothing: set fso=nothing<BR>Const adTypeBinary = 1<BR>Response.Clear<BR>Set objStream = Server.CreateObject("ADODB.Stream")<BR>objStream.O pen<BR>objStream.Type = adTypeBinary<BR>objStream.LoadFromFile strFilePath<BR>strFileType = "application/msword" &#039; change to the correct content type for your file<BR>Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName<BR>Response.AddHeader "Content-Length", strFileSize<BR>Response.ContentType = strFileType<BR>Response.BinaryWrite objStream.Read<BR>Response.Flush<BR>objStream.Clos e<BR>Set objStream = Nothing<BR>%&#062;<BR><BR>thanks for the help<BR>ger<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Forcing a file downoad when files are on diffe

    strFilename = Request.QueryString("file")<BR>strFilePath=server. mappath("/fiscintranet_dev/Dat/PPI Stage/"&strFilename) <BR><BR><BR>That gives you a file path on the hard drive. If you want to pass it a full path:<BR>strFilePath = Request.QueryString("filepath")<BR><BR>Bear in mind security issues, but yeah, that&#039;s all you NEED to do.<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts