下载文件

admin2年前Laravel757

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

相关文章

设置项目编号

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

腾讯云发送短信

<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;use Illuminate\Support\Facades\DB...

不重复 的推荐码

public function getcode(){    do {        $code = rand(10000000, 99999...

发送公众号信息

* 发送消息 */public function tosend($openid, $title, $content, $time, $aid){    $tokens = $thi...

验证手机号

public function phone($phone){    $pat = '/'        . '^13...

忘记密码

publicfunction forget(){    $phone = request()->input('phone');    $c...