Home > Backend Development > PHP Tutorial > PHP header jump IE problem_PHP tutorial

PHP header jump IE problem_PHP tutorial

WBOY
Release: 2016-07-13 17:52:00
Original
762 people have browsed it

The movie site provides torrent downloads of movies. Since it uses Polyton player, when uploading a movie, a hash file of the movie will be uploaded at the same time. Using this hash file, the corresponding bt seed is dynamically generated and saved (specified path) when requested for the first time and provided for download. When the user clicks to download a bt seed, first go to the corresponding directory to check whether the corresponding bt seed file exists. If it exists, it will be directly provided for download. Otherwise, it will be generated first and then downloaded.

The download of Bt seeds uses header jump directly in the file. The php file itself is gbk encoded.

Later I found that it works normally in Chrome, Firefox and IE6, but in IE8 there will be a situation where files cannot be found and opened. This makes me very depressed. IE6 can work, but IE8 still has problems.

[php]
//Point to torrent file, provide download
//$torrent_file_url = "torrent/tyvod1/science fiction film/Thor.torrent"
$redirect_url = "http://vod.cqjtu.edu.cn/".$torrent_file_url;
Header("HTTP/1.1 303 See Other");
Header("Location: ".$redirect_url);
exit ();
After comparative testing, it was found that if there is Chinese in the path, ie8 cannot download it. The php file itself is GBK encoded, so we convert the gbk encoded string to utf8 encoding before jumping.

[php]
//Point to torrent file, provide download
//$torrent_file_url = "torrent/tyvod1/science fiction film/Thor.torrent"
$redirect_url = "http://vod.cqjtu.edu.cn/".$torrent_file_url;
Header("HTTP/1.1 303 See Other");
Header("Location: ".iconv("gbk","utf-8",$redirect_url));
exit ();
Now, there is no problem in Chrome, Firefox, IE8 and IE9, but it cannot be downloaded in IE6. Chinese garbled characters. After checking the information, it was said that it is because ie6's support for UTF-8 is not perfect enough. Damn it, IE is really difficult to handle. Whether it is GBK encoding or UTF-8 encoding, Chrome and Firefox can correctly parse it. IE's own brother actually has such a problem.

I didn’t find a good way, so I had to do it specifically for ie6...
[php]
//Point to torrent file, provide download
//$torrent_file_url = "torrent/tyvod1/science fiction film/Thor.torrent"
$redirect_url = "http://vod.cqjtu.edu.cn/".$torrent_file_url;
Header("HTTP/1.1 303 See Other");
if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 6.0')===false){//non-ie6
Header("Location: ".iconv("gbk","utf-8",$redirect_url));
}else{//ie6
Header("Location: ".$redirect_url);
}
exit ();
Author: jdluojing

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478141.htmlTechArticleThe movie station provides movie bt downloads. Due to the use of Polyton player, when uploading a movie, a movie will be uploaded at the same time. hash file. Using this hash file, the first request is dynamically generated...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template