php实现文件的下载

public function download($path){
    
    $file=htmlspecialchars_decode(file_get_contents($path));
    $outfile=basename($path);
    header('Content-type: application/octet-stream; charset=utf8');
    Header("Accept-Ranges: bytes");
    header('Content-Disposition: attachment; filename='.$outfile);
    echo $file;
}

你可能感兴趣的:(PHP)