php文件下载

如果是一个下载链接直接处理

$downloadUtrl = "http://test.cn/test/assets/images/12.png"

     (一)

       headers = get_headers($downloadUtrl, 1);
        $content_type = isset($headers['Content-Type']) ? $headers['Content-Type'] : '';
        $content_disposition = isset($headers['Content-Disposition']) ? $headers['Content-Disposition'] : '';
        header('Content-type: ' . $content_type);
        header('Content-Disposition: ' . $content_disposition);
        readfile($filePath);
        return;
        (二)
        
         header('location:'.$downloadUtrl);

你可能感兴趣的:(php开发,工作笔记)