Exemplo n.º 1
0
 public function view_downLoadAttach()
 {
     $mid = isset($_GET['mid']) ? $_GET['mid'] : 0;
     $msg_obj = new amazonmessageModel();
     $msginfo = $msg_obj->getMessageInfo(array($mid))[0];
     $attachname = $msginfo['attachname'];
     $attachpath = WEB_PATH . 'crontab/' . $msginfo['attachpath'];
     if (!file_exists($attachpath)) {
         die('附件不存在');
     }
     $fp = fopen($attachpath, 'r');
     $fsize = filesize($attachpath);
     header("Content-type:text/html;charset=utf-8");
     Header("Content-type: application/octet-stream");
     Header("Accept-Ranges: bytes");
     Header("Accept-Length:" . $fsize);
     Header("Content-Disposition: attachment; filename=" . $attachname);
     $buffer = 1024;
     while (!feof($fp)) {
         $file_con = fread($fp, $buffer);
         echo $file_con;
     }
     fclose($fp);
 }