-
Building a File Download Script
I am building a download script that will allow users to download files from
a directory that is not on the web server and cannot be a shared web
directory. I wrote a COM object that returns the byte array data for the
file which I send out using the BinaryWrite Method of the Response Object.
The following code works great and will allow the successful download of any
file, but when the standard file download box comes up it says...
"You have chosen to download a file from this location
download.asp?hello.txt from ServerName"
I would really like to drop all reference to download.asp from the message
and simply reference the file they are downloading like you normally see
when you download files, but I think that I am missing or have an incorrect
header somewhere. Any ideas?
---This is the ASP page download.asp---
<%@ Language=VBScript %>
<%
Set MyCom = Server.CreateObject("BinaryCOM.Binary")
FileReturn = MyCom.ReturnByteArray(Request.QueryString("File"))
Set MyCom = Nothing
Response.ContentType = "application/x-msdownload"
Response.AddHeader "Content-Length", Ubound(FileReturn) + 1
Response.AddHeader "Content-Disposition", "attachment; filename=" &
Request.QueryString("File")Response.binaryWrite FileReturn
%>
---This is the html code I use to call the download page---
<a href="download.asp?File=hello.txt">hello.txt</a>
Thanks for any tips.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks