BellaOnline
Posted By: kirstie7965 Force download script - 11/11/06 06:25 PM
I've followed the directions for the Force Download Dialog box but I receive an error message:

Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.


Microsoft suggested I remove the AddHeader line which I did. (more documentation here )

I'm still receiving the same error. I'm very new to ASP and the little html I know is self-taught. Any assistance would be greatly appreciated!
Posted By: kirstie7965 Re: Force download script - 11/14/06 06:30 PM
40 views and no responses???
Posted By: Chris_ASP_Developer Re: Force download script - 11/14/06 06:48 PM
Sorry about that. for some reason, I do not get a notification when a new post is placed. this is being worked out. With that said....

What is the error you are getting?
Posted By: kirstie7965 Re: Force download script - 11/14/06 07:25 PM
Thanks, Chris!

I've been testing this with a .doc file. The dialog box opens but when I try to 'save' I receive the error: "Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."

If I choose open, I receive the error: "Internet Explorer cannot download file.doc from xpressassistant.com. The requested site is either unavailable or cannot be found. Please try again later."

I don't know if it matters but I'm using shared windows hosting thru godaddy, running asp.net 2.0. Previously I had asp 1.1 but received the same errors.

Also, I have a data file specific to my client's software. It has a .bku extension. When I try to download or open that file, I receive the following:

" <font face="Arial" size=2>
<p>ADODB.Stream</font> <font face="Arial" size=2>error '800a0bba'</font>
<p>
<font face="Arial" size=2>File could not be opened.</font>
<p>
<font face="Arial" size=2>/filedownloader.asp</font><font face="Arial" size=2>, line 38</font>"
Posted By: digijin Re: Force download script - 11/30/06 03:02 AM
what happens on line 38 of filedownloader.asp?

asp.net is different than asp, you probably have asp1.1 AND asp.net 2.0
Posted By: kirstie7965 Re: Force download script - 12/01/06 03:43 PM
This is the script as written by Chris:

<%
'=======================
'Define the names of your functions
'=======================
Dim Stream
Dim Contents
Dim FileName
Dim FileExt
Const adTypeBinary = 1
'=======================
'Get the actual file name from the URL that is passed to the browser
'=======================
FileName = request.querystring("filename") 'Get the name from the URL
'=======================
'GIVE AN ERROR MESSAGE IF THE URL IS EMPTY
'=======================
if FileName = "" Then
response.write "Filename Not specified."
response.end
end if
'=======================
'prevent access to certain files
'=======================
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
select case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
response.write "You cannot access these file types."
response.end
end select
'=======================
'Start the download process if all is good
'=======================
response.clear
response.contentType = "application/octet-stream"
response.addheader "content-disposition", "attachment; filename=" & FileName
set stream = server.CreateObject("ADODB.Stream")
stream.type = adTypeBinary
stream.open
stream.LoadFromFile Server.MapPath("/files") & FileName
while not stream.EOS
response.BinaryWrite Stream.Read(1024 * 64)
wend
stream.Close
Set stream = Nothing
response.Flush
response.End
%>

So, if asp.net is different does that mean that this script won't execute properly? If so, do you think you could point me in the direction of a script that will work? I really appreciate the assistance.....I've received no response from Chris.
Posted By: Tuck Re: Force download script - 02/08/07 08:45 PM
Just fell across this article on Forcing a Download. I really wish to be able to give an option to download a video I have stored on my site. Here are the conditions of my site:
download.asp is stored in folder ipod
videos are stored in ipod/videos/download
when I visit: ipod/download.asp?filename=ClockInOutEnglish_Subs.m4v to download ClockInOutEnglish_Subs.m4v, I get the following:
Quote:
The website cannot display the page
HTTP 500
Most likely causes:
The website is under maintenance.
The website has a programming error.
Here is the code I'm using:
Code:
<%
'=======================
'Define the names of your functions
'=======================
Dim Stream
Dim Contents
Dim FileName
Dim FileExt
Const adTypeBinary = 1
'=======================
'Get the actual file name from the URL that is passed to the browser
'=======================
FileName = request.querystring("filename") 'Get the name from the URL
'=======================
'GIVE AN ERROR MESSAGE IF THE URL IS EMPTY
'=======================
if FileName = "" Then
response.write "Filename Not specified."
response.end
end if
'=======================
'prevent access to certain files
'=======================
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
select case UCase(FileExt)
Case <> "M4V"
response.write "You cannot access these file types."
response.end
end select
'=======================
'Start the download process if all is good
'=======================
response.clear
response.contentType = "application/octet-stream"
response.addheader "content-disposition", "attachment; filename=" & FileName
set stream = server.CreateObject("ADODB.Stream")
stream.type = adTypeBinary
stream.open
stream.LoadFromFile Server.MapPath("/video/download") & FileName
while not stream.EOS
response.BinaryWrite Stream.Read(1024 * 64)
wend
stream.Close
Set stream = Nothing
response.Flush
response.End
%>
Posted By: Neil040 Re: Force download script - 02/18/07 06:21 PM
I also had problems with this script. I was able to get it mostly working but calling the filename just would now work.. only if I put the actual filename in the server.mappath part. I just could not get it to work with a mappath and then the & FileName part. Drove me mad as it is a nice script and others I have found did not include the file exclusions.

I finally cracked it as below.. on the line

stream.LoadFromFile Server.MapPath("/files") & FileName

I set it thus..

stream.LoadFromFile Server.MapPath(FileName)

Now it works perfectly!

Thanks for the script.. altho it had me tearing what is left of my hair out! smile

Neil
Posted By: Suebeedoo Re: Force download script - 03/29/07 09:22 AM
Hi!

I had the same problems with this and I'm very new to asp, so was completely lost! Neil's solution solved it for me, however I really wanted the files in a separate folder from the asp page. I got round this by replacing

stream.LoadFromFile Server.MapPath("/files") & FileName

with

stream.LoadFromFile Server.MapPath("/files" & FileName)

This works too!

Thanks Neil

Sue
© BellaOnline Forums