下载文件

admin2年前Laravel842

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 wxlogin(){       $code = request()->input('code'); &n...

过滤违禁词

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

微信退款v2

/** * 微信 退款 操作 */ public function refund($out_trade_no, $total_fee) { $parma =...

设置项目编号

$max = Db::table('member')->max('id') ?? 0; if ($max < 100000) { $cd = $this->create...

手机号替换

 $vv = substr_replace($vv, '****', 3, 4) ....

生成唯一的订单号

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