<% strFileName="test.xsl" strFilePath="c:\inetpub\wwwroot\test.xsl" strFileSize=n '获取文件长度 Set objStream = Server.CreateObject("ADODB.Stream") '创建流对象 objStream.Open objStream.Type = adTypeBinary objStream.LoadFromFile strFilePath '装载要下载的文件 Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName '设置文件名 Response.AddHeader "Content-Length", strFileSize '设置文件长度 ' In a Perfect World, Your Client would also have UTF-8 as the default ' In Their Browser Response.Charset = "UTF-8" '设置编码类型 Response.ContentType = "application/octet-stream" '设置MIME类型 Response.BinaryWrite objStream.Read '输出到浏览器 Response.Flush
objStream.Close Set objStream = Nothing %> 此方法可以用来下载任何类型的文件。
[此贴子已经被作者于2005-5-28 12:14:38编辑过]
Thanks,griefforyou ! 搞定,代码是: <% Dim strFilePathConst adTypeBinary = 1 strFilePath = "text/test.xls" Set objStream = Server.CreateObject("ADODB.Stream") objStream.Open objStream.Type = adTypeBinary objStream.LoadFromFile Server.MapPath(strFilePath) 'change the path if necessary Response.ContentType = "application/octet-stream" Response.AddHeader "Content-Disposition", "attachment; filename=留言--"&date()&".xls" '如果文件名固定,那就直接filename=文件名.doc,这个名字就是用户选“保存”时,出现的名字 Response.BinaryWrite objStream.Read Response.Flush objStream.Close Set objStream = Nothing '写完,释放对象 %> 请问把文件夹打包成压缩包怎么写?
我想连网站的图片也可以打包下载~!!
[此贴子已经被作者于2005-5-28 15:53:33编辑过]