public function exportsizetablehistoryAction(){
$params = $this->getRequest()->getParams();
$str = $params['str'];
if(empty($str)){
return false;
}
try {
//下载的核心代码 header控制
$strSize = strlen($str);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="filename.txt"');//下载的文件名
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . $strSize);//下载文件的大小
echo $str; //下载文件的内容
return true;
} catch (Exception $e) {
return false;
}
}