One, download any file:
Header("Content-type:application/octet-stream"); $ua=$_server["Http_user_agent"]; $encoded _filename=Rawurlencode($filename); if(Preg_match("/msie/",$ua)) { Header(' Content-disposition:attachment; Filename= '.$encoded _filename. ‘"‘); } Else if(Preg_match("/firefox/",$ua)) { Header("Content-disposition:attachment; Filename*=\ "UTF8".$filename. ‘"‘); } Else { Header(' Content-disposition:attachment; Filename= '.$filename. ‘"‘); } $file= ' Xxxx.pdf '; Header("Content-length:".)filesize("{$file}"));
Second, Phpexcel export Excel file Download:
.....
$objWriter= Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel5 '); Header(' Content-type:application/vnd.ms-excel '); $ua=$_server["Http_user_agent"]; $encoded _filename=Rawurlencode($filename); if(Preg_match("/msie/",$ua)) { Header(' Content-disposition:attachment; Filename= '.$encoded _filename. ‘"‘); } Else if(Preg_match("/firefox/",$ua)) { Header("Content-disposition:attachment; Filename*=\ "UTF8".$filename. ‘"‘); } Else { Header(' Content-disposition:attachment; Filename= '.$filename. ‘"‘); } Header(' Cache-control:max-age=0 '); $objWriter->save (' php://output ');