php下载文件无法在移动设备上运行

时间:2016-01-12 10:49:56

标签: php

if (file_exists($file)) {                                 
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . $filename. "." . $exts );
    flush();
    readfile($file);
    exit;
}

此代码适用于PC,但在移动设备上我无法打开该文件。标题不正确?

1 个答案:

答案 0 :(得分:0)

尝试添加:

header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));

header('Content-Disposition: attachment; filename=' . $filename. "." . $exts );