下载文件

admin6个月前Laravel260

public function img_url()
{
    $id = request()->param('id', 1122);
    $info = Db::name('attachment')->where(array('id' => $id))->find(); if ($info['drawing']) {
        $filename = substr($info['drawing'],1);
    } else {
        $filename = substr($info['url'],1);
    } 
 Header("Content-type: application/octet-stream");
     Header("Accept-Ranges: bytes");
   Header("Accept-Length: " . filesize($filename));
   Header("Content-Disposition: attachment; filename=" . basename($filename));
   header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
 header('Pragma: public'); 
 echo file_get_contents($filename); 
 exit();
}

相关文章

获取域名

/** * 获取域名 */public function domain(){    return request()->getSchemeAndHttpHost();}...

解密微信绑定的手机号

public function mobile() { $code = request()->input('code'); if (!$code) { return $this-&...

生成唯一的订单号

public function get_order_sn() {     return date('Ymd') ...

百度浏览器中视频悬浮

  <video class="html5-video"                poster=...

公众号登录

public function wxlogin(){       $code = request()->input('code'); &n...

批量处理数据

   public function index44()    {        $domain = request(...