Android浏览器/网页流量的错误?内容处置:附件;文件名= QUOT; xyz.txt将该"文件名、将该、流量、附件

2023-09-06 22:17:13 作者:愛迩花光了涐所有勇氣

因此​​,一个Android浏览器或网页视图工作正常,像这样的URL - abc.com/xyz.txt

不过,如果你的URL看起来像这样 - abc.com/xyz.php,什么是发送到浏览器的标题是 - 内容处置:附件;文件名=xyz.txt将该,那么Android的浏览器和Web视图似乎变得非常混乱。

它看起来像它保存在手机上正确的文件名,但内容充满了,这是previously正在浏览的网页。这完美的作品以及基于PC浏览器,并在iPhone和黑莓,这只是在Android 2.1和2.2(没有测试等)的问题。

任何人都有一个解决方案吗?将非常感激。我的真正的不想开始储存静态文件和要生成动态我的下载内容。在手机上的日志也没有发现线索。

下面是什么由服务器发送到浏览器

  =====================开始内容=============== =====================HTTP / 1.1 200 OK日期:星期四,2010 GMT 21点22分11秒10月21日服务器:Apache内容处置:附件;文件名=Wafty.txt内容长度:30内容类型:text / plain的;字符集= ISO-8859-1你好这是一个文件的一个测试=========有在上述行的末尾没有回车==== 

解决方案 Android手机浏览器横评之 谁最快最省

使用

 内容处置:附件;文件名=xyz.txt将该 

不要用

 内容处置:附件;文件名=xyz.txt将该 

So an android browser or a webview works fine with urls like this - abc.com/xyz.txt

However, if your URL looks like this - abc.com/xyz.php and what's sent to the browser in the headers is - Content-Disposition: attachment; filename="xyz.txt", then the Android browsers and web view seems to get terribly confused.

It looks like it saves the correct file name on the phone, but the contents is filled with the webpage that was previously being viewed. This works perfectly well on PC based browsers and on an iPhone and Blackberry, it's only a problem on the Android 2.1 and 2.2 (haven't tested others).

Anyone have a solution? Will be very grateful. I really don't want to start storing static files and want to generate my download content on the fly. The log on the phone has revealed no clues.

Here's what's sent by the server to the browser

===================== start content ====================================
HTTP/1.1 200 OK
Date: Thu, 21 Oct 2010 21:22:11 GMT
Server: Apache
Content-Disposition: attachment; filename="Wafty.txt"
Content-length: 30
Content-Type: text/plain; charset=ISO-8859-1

Hello this is a test of a file
========= There was no carriage return at the end of the above line ====

解决方案

use

Content-Disposition: attachment;filename="xyz.txt"

do not use

Content-Disposition: attachment;  filename="xyz.txt"

 
精彩推荐