Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force a Download from ASP

Status
Not open for further replies.

tsorial

Programmer
May 9, 2002
5
US
Hi,

Given a URL to a file, is there way in ASP to force a download on this file when the User clicks a button that points to this link. Once the button is clicked, the open/save as dialog should be displayed.

I have tried doing this by using ADODB.Stream object but the server that I am using fails to create this object.

Your urgent help is greatly appreciated.

 
May someone please help me! I need this urgently.
 
No way to use the ADODB for downloading normaly you have to use a link to the file to be downloaded as you do in html pages. Or just use a redirect from page named redir.asp
in the link to the file u wanadownload type redir.asp?[TheFileToDwnLoad]
ex: redir.asp?myfile.zip

<%
response.buffer = true
%>

<SCRIPT type=&quot;text/javascript&quot;>
function openurl() {
var win = window.open(&quot;&quot;)
if (win) win.onload = openurl }


</SCRIPT>
<%
Dim TheFile
Thefile= Request.QueryString()
thelink=&quot;'&quot; & Request.QueryString() & &quot;'&quot;
%>
<HTML>
<HEAD>
<TITLE>Dwonload in progress...</TITLE>
<STYLE type=text/css>
A:hover {TEXT-DECORATION: none}
</STYLE>
</HEAD>
<BODY background=&quot;f&quot; text=&quot;#000000&quot; aLink=#000099 vLink=#000099 link=#000099 topmargin=&quot;0&quot; leftmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; onLoad=&quot;openurl=window.open(<%=TheLink%> , '_blank')&quot; ,>

</Body>
</Html>
 
I appreciate your help, lelamour. I have tried your idea, but for a jpg file the file is opened directly onto the browser. Is there a way to bring up the open/save as dialog for any type of file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top