Home > Archive > ASP > December 2006 > File Download dialog box
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
File Download dialog box
|
|
|
| http://classicasp.aspfaq.com/genera...-mime-type.html
I have the below code borrowed from above to open a "save as.." filedownload
dialog box.
The dialog box will open and prompt me to save the right filename. Great!
Problem: the file is saved at 0 bytes. No content! No errors!
<%
Response.ContentType = "application/x-unknown" ' arbitrary
fn = (rsFileDownload.Fields.Item("FileNam").Value)
FPath = "http://www.mydomain.com" &
(rsFileDownload.Fields.Item("Folder").Value) & fn
Response.AddHeader "Content-Disposition","attachment; filename=" & fn
Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(FPath)
Response.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing
Response.End
%>
So, to troubleshoot, I wrote these out...
<%=fn%><br>
<%=FPath%><br>
....then cut-n-pasted the full link in my browser address bar.
And everything downloaded fine.
So, the link is good.
What's going wrong here?
thanks
| |
|
| OK... I think I figured it out.
1) I had to use local link: c:\inetpub\... (then it only worked part of the
time)
2) I used the code shown at the bottom of aspfaq link below. Seem to be
working now.
thanks
"shank" <shank@tampabay.rr.com> wrote in message
news:OQmNtSAGHHA.5000@TK2MSFTNGP03.phx.gbl...
> http://classicasp.aspfaq.com/genera...-mime-type.html
>
> I have the below code borrowed from above to open a "save as.."
> filedownload dialog box.
> The dialog box will open and prompt me to save the right filename. Great!
> Problem: the file is saved at 0 bytes. No content! No errors!
>
> <%
> Response.ContentType = "application/x-unknown" ' arbitrary
> fn = (rsFileDownload.Fields.Item("FileNam").Value)
> FPath = "http://www.mydomain.com" &
> (rsFileDownload.Fields.Item("Folder").Value) & fn
> Response.AddHeader "Content-Disposition","attachment; filename=" & fn
>
> Set adoStream = CreateObject("ADODB.Stream")
> adoStream.Open()
> adoStream.Type = 1
> adoStream.LoadFromFile(FPath)
> Response.BinaryWrite adoStream.Read()
> adoStream.Close
> Set adoStream = Nothing
>
> Response.End
> %>
>
> So, to troubleshoot, I wrote these out...
>
> <%=fn%><br>
> <%=FPath%><br>
>
> ...then cut-n-pasted the full link in my browser address bar.
> And everything downloaded fine.
> So, the link is good.
> What's going wrong here?
>
> thanks
>
|
|
|
|
|