ASP代码中将图像插入代码后,尽管图像仍然可以正常显示,但文件的内容和大小已经更改,下面是错新技术频道小编带给大家的ASP实现强制图片下载函数,一起来看看吧!
function downloadFile(strFile) strFilename = server.MapPath(strFile) Response.Buffer = True Response.Clear Set s = Server.CreateObject("ADODB.Stream") s.Open s.Type = 1 on error resume next Set fso = Server.CreateObject("Scripting.FileSystemObject") if not fso.FileExists(strFilename) then Response.Write("
") Response.End end if Set f = fso.GetFile(strFilename) intFilelength = f.size s.LoadFromFile(strFilename) if err then Response.Write("
") Response.End end if Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name Response.AddHeader "Content-Length", intFilelength Response.CharSet = "UTF-8" Response.ContentType = "application/octet-stream" Response.BinaryWrite s.Read Response.Flush s.Close Set s = Nothing End Function
上文是错新技术频道小编给大家整理的ASP实现强制图片下载函数,希望对大家学习这方面知识有所帮助,也希望大家能继续支持js.VeVb.com!
新闻热点
疑难解答