php 文件流输出

 
  


public function download(){

    $fileName = trim($_REQUEST['fileName']);

    $outFileName = "aaa.excel";
    $path = './data/uploads/';

    $outFileName = iconv("UTF-8", "GB2312", $outFileName);//解决文件名乱码
    // 设置下载头信息
    header ( "Content-Type: application/vnd.ms-excel" );
    header ( "Content-Disposition: attachment; filename=".$outFileName );

    // 文件流输出到浏览器
    readfile ($path . $fileName);
    // 删除文件
    @unlink($path . $fileName);

}

window.location.href = url;

你可能感兴趣的:(PHP学习)