PHP 在浏览器界面下载文件

分类:代码片段 时间:2021-11-12 浏览:18
0
//http://oss.fpga.love/demo_zf_test/upload/simple/image/20200923/1600831913_ALINX%20FPGA%E4%BA%A7%E5%93%81%E6%89%8B%E5%86%8C2020.8.pdf
                ob_start();  
                $filename=$str;  
                $title=substr($filename,strrpos($filename,'/')+1);  
                $size=readfile($filename);  
                //var_dump($size);exit;  
                Header( "Content-type:application/octet-stream");  
                Header( "Accept-Ranges:bytes");  
                Header( "Accept-Length:");  
                header( "Content-Disposition:  attachment;  filename= $title");  
                exit;


本站文章如未注明出处则为原创,转载请注明出处,如有侵权请邮件联系站长

用户评论

评论前必须