Download – IE9 streaming files to browser when suspended

I use the following methods to stream files (usually Excel or PDF) to my browser It operates by setting the location of the hidden iframe to the download handler that contains the code

It works normally in Firefox, some instances of IE9, but not other instances of IE9

The inactive information bar appears, but there is no option to open, just save or cancel

The message bar is then suspended and cannot be closed or cancelled

In addition, the URL is changed to change the point before the file prefix (such as. XLS or. PDF) to underline

A typical correct is

/export_templates/rawdata/downloadfile7.asp?fID=@_pdf@{875CFEE5-23D4-42CB-8885-7A9D493DC616}.pdf&fname=Quick%5Fpoll.pdf

Has anyone seen this or found a fix The add in is not enabled and will not be stopped We compared the settings of IE, AV and firewall on the machine, and they didn't work, and they were the same

Set adoStream = CreateObject("ADODB.Stream")
adoStream.open()
adoStream.Type = 1
adoStream.LoadFromFile(f.Path)
dataSize = f.size
Response.Buffer = true
Response.CharSet = "UTF-8"
Response.clear
Response.ContentType = "application/x-unkNown" ' arbitrary
response.addheader "Content-Length",dataSize
response.addheader "Content-Disposition","attachment;filename=" & thisfname

Response.flush
do while not adoStream.eos
    Response.BinaryWrite adoStream.Read(1024 * 8)
    Response.flush
loop
Response.End()
adoStream.close
set adoStream=nothing

Solution

I see that the above code has two potential problems and two potential "mitigation situations":

1.) do not reference file names Problems encountered during use:

Content-Disposition:attachment; filename = File Name. PDF and content disposition: attachment; filename =“File Name.pdf”

Note the double quotation marks of the file name This is important when the name contains spaces or other unsafe characters

2.) wrong content type As mentioned in the above note, this is an important clue to how the system should handle files For PDF, you really should use application / PDF

3.) different transmission codes This problem can only affect gzipped (deflate) content Ie cannot properly handle compressed streams for the first time

4.) if you see different results between copies of the same browser, you should try to determine whether they have the same minor version and OS, plugins, toolbars and PDF readers Any of these things can be a factor

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>