下载文件

admin1年前Laravel528

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();
}

相关文章

按照距离远近排序

   $distance = "ACOS(SIN(( $lat * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((...

微信开放平台-扫码登录

public function wx_info(){    $code = request()->input('code');    if...

过滤违禁词

/** * 内容验证 */public function check($content){    $count = 0; //违规词的个数    $list =...

解密微信绑定的手机号

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

生成二维码

public function qrcode($uid){    require_once base_path() . '/public/phpqrcode/phpqrco...

修改密码

/** * 修改密码 */publicfunction setpass(){    $type = request()->input('type');// 1...