我想解决下载文件到php 我使用这种方式下载文件,但获得问题下载文件代码
$filename = '[file name].[extension]';
$file="application/[extension]";
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
问题:
答案 0 :(得分:0)
以下是下载文件的基本示例 -
$file="http://example.com/filename.mp3"; // your filename with path
header("Content-type: application/x-file-to-save");
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
exit;
答案 1 :(得分:0)
尝试按照变量指示操作....使用文件路径而不是文件名
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($dest_file_path));
header('Content-Type: text/xml');
header('Content-Disposition: attachment; filename="'.$dest_file_name.'"');
readfile($dest_file_path);