$arr = Array (1,2,3,4);
$file _data = Json_encode ($res);
$download _filename = ' 123.json ';
$http _user_agent = $_server[' http_user_agent ');
Header ("Content-type:application/octet-stream");
if (Preg_match ("/msie/", $http _user_agent)) {
Header (' Content-disposition: attachment; filename= "'. $download _filename. '");
} elseif (Preg_match ("/firefox/", $http _user_agent)) {
Header (' content-disposition:attachment; filename*= ' UTF8 '. $download _filename. ‘"‘ );
} else {
Header (' Content-disposition: attachment; filename= "'. $download _filename. '");
}
Header ("Accept-length:". strlen ($file _data));
echo $file _data;
Try, Google browser, Firefox browser can be downloaded directly;
IE browser if the following pop-up window:
Solution: In the IE menu bar "page"--"encoding", select "Auto Select" and then download try.
360 browsers also have this problem, pending testing.
PHP Download file