很多站长朋友们都不太清楚html下载代怎么写,今天小编就来给大家整理html下载代怎么写,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 html下载文件代码,就是点击按钮下载指定文件? 2、 html中点击下载的代码怎么写 3、 html中点击下载的代码怎么写? html下载文件代码,就是点击按钮下载指定文件?1、在a标签中指定href='文件路径',download='文件名';这样直接点a标签就能下载文件了。
2、给按钮绑定个click事件,在事件里使用window.location.href='文件路径',或者window. open("文件路径")
3、如果需要从后台查询文件,也可以直接后台返回流也行的
html中点击下载的代码怎么写<%
function download(f,n)
'f文件全路径,n下载文件的文件名
on error resume next
Set S=CreateObject("Adodb.Stream")
S.Mode=3
S.Type=1
S.Open
S.LoadFromFile(f)
if Err.Number>0 then
Reaponse.status="404"
else
Response.ContentType="application/octet-stream"
Response.AddHeader "Content-Disposition:","Attachment;filename="n
Range=Mid(Request.ServerVariables("HTTP_RANGE"),7)
if Range="" then
Response.BinaryWrite(S.Read)
else
S.Postion=Clng(Split(Range,"-")(0))
Response.BinaryWrite(S.Read)
end if
end if
Response.end
end function
dim filename
d=replace(request("d"),"","")
d=replace(d,".asp",".err")
'必须防止下载asp文件。
filename="down/"d
'response.write filename
call download(server.MapPath(filename),d)
%>
这是我用过的。下载word 等都符合你的要求,不会直接打开。
html中点击下载的代码怎么写?目标:实现点击链接弹出文件下载对话框。
代码:
<html>
<head>代码下载</head>
<title>代码下载</title>
<body>
<a href="Web.rar" >download</a>
</body>
</html
浏览器支持能够打开的格式,他都会默认直接在线打开(比如word或图片),不支持的格式,他就会弹出下载提示。最好是做成.rar格式的文件。
关于html下载代怎么写的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于html下载代怎么写 html代码怎么下载的详细内容...