zoukankan      html  css  js  c++  java
  • 关于让浏览器默认弹出下载而不用直接在浏览器打开的封装方

    其实就是将你的的文件,通过二进制的方法,转成流文件让浏览器识别,或者替换头部信息的方式

        function downFileFromServer($showFileName, $downFilePath)    {        if(file_exists($downFilePath))        {            if(is_readable($downFilePath))            {                if(Trim($showFileName) == '')                {                 $showFileName = 'undefined';                }                ob_start();                ob_clean();                $file_size = filesize($downFilePath);                header('Content-Encoding:none');                header('Cache-Control:private');                header('Content-Length:' . $file_size);                header('Content-Disposition:attachment; filename=' . $showFileName);                header('Content-Type:application/octet-stream');                readfile($downFilePath);                ob_flush();            }        }    }    //Sample     downFileFromServer($fileurl, 真实文件地址);

  • 相关阅读:
    RA-Embedding-based Retrieval in Facebook Search
    RA-Recommending What Video to Watch Next: A Multitask Ranking System
    家事杂谈-2
    工作体会-3
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
  • 原文地址:https://www.cnblogs.com/kakaxi/p/1967763.html
Copyright © 2011-2022 走看看