asp利用adodb.stream组件生成文件带BOM问题
利用asp的adodb.stream组件生成的文件全部包括Unicode签名(BOM)如何让生成的新文件不带BOM我手动肯定行可是生成的文件多的话不可能一个一个的去手动改...
利用asp的adodb.stream组件生成的文件全部 包括 Unicode 签名(BOM)如何让生成的新文件不带BOM我手动肯定行 可是生成的文件多的话 不可能一个一个的去手动改
展开
1个回答
2013-07-29
展开全部
download.asp?file=相对路径的文件
就可以把这个文件下载下来
<%
2
3 call downloadfile(replace(replace(request("file"),"\",""),"/",""))
4
5 function downloadfile(strfile)
6 make sure you are on the latest mdac version for this to work
7 -------------------------------------------------------------
8
9
10 get full path of specified file
11 strfilename = server.mappath(strfile)
12
13
14 clear the buffer
15 response.buffer = true
16 response.clear
17
18 create stream
19 set s = server.createobject("adodb.stream")
20 s.open
21
22 set as binary
23 s.type = 1
24
25 load in the file
26 on error resume next
27
28
29 check the file exists
30 set fso = server.createobject("scripting.filesystemobject")
31 if not fso.fileexists(strfilename) then
32 response.write("<h1>error:</h1>" & strfilename & " does not exist<p>")
33 response.end
34 end if
35
36
37 get length of file
38 set f = fso.getfile(strfilename)
39 intfilelength = f.size
40
41
42 s.loadfromfile(strfilename)
43 if err then
44 response.write("<h1>error: </h1>" & err.description & "<p>")
45 response.end
46 end if
47
48 send the headers to the users browser
49 response.addheader "content-disposition", "attachment; filename=" & f.name
50 response.addheader "content-length", intfilelength
51 response.charset = "utf-8"
52 response.contenttype = "application/octet-stream"
53
54 output the file to the browser
55 response.binarywrite s.read
56 response.flush
57
58
59 tidy up
60 s.close
61 set s = nothing
62
63
64 end function
65
66 %>
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
就可以把这个文件下载下来
<%
2
3 call downloadfile(replace(replace(request("file"),"\",""),"/",""))
4
5 function downloadfile(strfile)
6 make sure you are on the latest mdac version for this to work
7 -------------------------------------------------------------
8
9
10 get full path of specified file
11 strfilename = server.mappath(strfile)
12
13
14 clear the buffer
15 response.buffer = true
16 response.clear
17
18 create stream
19 set s = server.createobject("adodb.stream")
20 s.open
21
22 set as binary
23 s.type = 1
24
25 load in the file
26 on error resume next
27
28
29 check the file exists
30 set fso = server.createobject("scripting.filesystemobject")
31 if not fso.fileexists(strfilename) then
32 response.write("<h1>error:</h1>" & strfilename & " does not exist<p>")
33 response.end
34 end if
35
36
37 get length of file
38 set f = fso.getfile(strfilename)
39 intfilelength = f.size
40
41
42 s.loadfromfile(strfilename)
43 if err then
44 response.write("<h1>error: </h1>" & err.description & "<p>")
45 response.end
46 end if
47
48 send the headers to the users browser
49 response.addheader "content-disposition", "attachment; filename=" & f.name
50 response.addheader "content-length", intfilelength
51 response.charset = "utf-8"
52 response.contenttype = "application/octet-stream"
53
54 output the file to the browser
55 response.binarywrite s.read
56 response.flush
57
58
59 tidy up
60 s.close
61 set s = nothing
62
63
64 end function
65
66 %>
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询