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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"download" button

Status
Not open for further replies.

looperboy

Technical User
Dec 12, 2003
37
DE
can I use microsoft frontpage to create a button that will download a file to the users computer when clicked?
 
yes, you can do that.
Code:
<input type=button value=&quot;Download File&quot; onclick=&quot;document.location='myfile.zip'&quot;>

________
George, M
 
thanks shaddow. is the only value in there that I'd have to change the 'myfile.zip' value? all the rest I just enter as it is?
 
I belive this will only work with files not associated wiht any application. If the file is associated, then it will be opened directly from the browser. For example MS Word document (if installed on client) would open the download link wihtout presenting the download dialog :(

&quot;Taxes are the fees we pay for civilized society&quot; G.W.
 
Yes but for this use this piece of code
Code:
<input type=button value=&quot;Download File&quot; onclick=&quot;document.location='download.asp?filename=myfile.zip'&quot;>


download.asp
<%
fileName=Request(&quot;filename&quot;)
filePath=Server.MapPath(&quot;downloads/&quot;&fileName)
set rs=Server.CreateObject(&quot;ADODB.Stream&quot;)
rs.Type = 1
rs.LoadFromFile filePath
Response.AddHeader &quot;Content-type&quot;,&quot;application/vnd.ms-excel&quot;
Response.AddHeader &quot;Content-Disposition&quot;,&quot;attachment; filename=&quot;&fileName
Response.BinaryWrite rs.Read(rs.Size)
%>

________
George, M
 
Yep, that is caled forced download.
Also i forgot to change the header
From
Response.AddHeader &quot;Content-type&quot;,&quot;application/vnd.ms-excel&quot;
To
Response.AddHeader &quot;Content-type&quot;,&quot;application/x-msdownload&quot;



________
George, M
 
is it possible to give this button a double function, so that it will force a download and at the same time submit the information from the form?
 
Yes, you can do that but you will needa an ASP Upload component or script

________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top