• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    ASP实现文件直接下载的代码
    %@ language=vbscript codepage=65001%>
    %
    'Filename must be input
    if Request("Filename")="" then
    response.write "h1>Error:/h1>Filename is empty!p>"
    else
    call downloadFile(replace(replace(Request("Filename"),"\",""),"/",""))

    Function downloadFile(strFile)
    ' make sure you are on the latest MDAC version for this to work
    ' get full path of specified file
    strFilename = server.MapPath(strFile)

    ' clear the buffer
    Response.Buffer = True
    Response.Clear

    ' create stream
    Set s = Server.CreateObject("ADODB.Stream")
    s.Open

    ' Set as binary
    s.Type = 1

    ' load in the file
    on error resume next

    ' check the file exists
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    if not fso.FileExists(strFilename) then
    Response.Write("h1>Error:/h1>"strFilename" does not exists!p>")
    Response.End
    end if

    ' get length of file
    Set f = fso.GetFile(strFilename)
    intFilelength = f.size

    s.LoadFromFile(strFilename)
    if err then
    Response.Write("h1>Error: /h1>Unknown Error!p>")
    Response.End
    end if
    ' send the headers to the users Browse
    Response.AddHeader "Content-Disposition","attachment; filename="f.name
    Response.AddHeader "Content-Length",intFilelength
    Response.CharSet = "UTF-8"
    Response.ContentType = "application/octet-stream"
    ' output the file to the browser
    Response.BinaryWrite s.Read
    Response.Flush
    ' tidy up
    s.Close
    Set s = Nothing
    End Function
    end if
    %>
    上一篇:一个sql查询器,自动画表格填字段
    下一篇:把网页中的(电话,qq等数字)生成图片的ASP程序
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    ASP实现文件直接下载的代码 ASP,实现,文件,直接,下载,