title: ASP Classic download file script
body: <p>I have a website being built in ASP Classic, and am having some trouble with a script that allows a user to download a file, but hides the path to the file.</p>
  
  <p>When a user is on a page, they will see a link. The link is coded like this:</p>
  
  <pre><code>&lt;a href="download.asp?file=FILE-NAME-HERE" target="_blank"&gt;Download File&lt;/a&gt;
  </code></pre>
  
  <p>This link takes them to download.asp where code is run to get the file and deliver it. Here is the code I have right now:</p>
  
  <pre><code>&lt;%
  const adTypeBinary = 1
  dim strFilePath, strFile
  
  strFilePath = "/_uploads/private/" 
  strFile = Request.QueryString("file") 
  
  if strFile &lt;&gt; "" then
      'Set the content type to the specific type that you are sending.
       Response.ContentType = "application/octet-stream"
       Response.AddHeader "Content-Disposition", "attachment; filename=" &amp; strFile
  
       set objStream = Server.CreateObject("ADODB.Stream")
       objStream.open
       objStream.type = adTypeBinary
       objStream.LoadFromFile(strFilePath &amp; strFile)
  
      response.binarywrite objStream.Read
  
      objStream.close
      Set objStream = nothing
  
  end if
  %&gt;
  </code></pre>
  
  <p>This code I put together from both questions on this site (<a href="https://stackoverflow.com/questions/12929866/how-to-download-the-files-using-vbscript-in-classic-asp">How to download the files using vbscript in classic asp</a>), and from <a href="http://support.microsoft.com/kb/276488" rel="nofollow noreferrer">http://support.microsoft.com/kb/276488</a></p>
  
  <p>What is happening, however, is that the download.asp page is giving me a "file not found" error, even though the file is correctly in the web directory "/_uploads/private/".</p>
  
  <p>The file type could be one of several, including pdf, xls, docx, etc.</p>
  
  <p>Is there something in my code that is not allowing the file to be found?</p>