codelayui.code

<button id="g80sy"></button>

codelayui.code

codelayui.code

codelayui.code

  • codelayui.code

    <abbr id="g80sy"></abbr>
  • <button id="g80sy"></button>

    codelayui.code

    codelayui.code

    codelayui.code

    codelayui.code

    <rt id="g80sy"><delect id="g80sy"></delect></rt>

    codelayui.code

  • php實現(xiàn)下載download

    程序猿 2021-02-09 22:48:12 2093瀏覽 加載中

    codelayui.code

    1. function download($file_sub_path, $file_name)
    2.     {
    3.         //用以解決中文不能顯示出來的問題
    4.         //$file_name=iconv("utf-8","gb2312",$file_name);
    5.         $file_sub_path = $file_sub_path;
    6.         $file_path = $file_sub_path . $file_name;
    7.         $file_path = str_replace("'", "", $file_path);
    8.         //首先要判斷給定的文件存在與否
    9.         if (!file_exists($file_path)) {
    10.             echo "沒有該文件";
    11.             return;
    12.         }
    13.         $fp = fopen($file_path, "r");
    14.         $file_size = filesize($file_path);
    15.         //下載文件需要用到的頭
    16.         Header("Content-type: application/octet-stream");
    17.         Header("Accept-Ranges: bytes");
    18.         Header("Accept-Length:" . $file_size);
    19.         Header("Content-Disposition: attachment; filename=" . $file_name);
    20.         $buffer = 1024;
    21.         $file_count = 0;
    22.         //一下兩行防止(格式未知 數(shù)據(jù)已被損壞)
    23.         ob_clean();
    24.         flush();
    25.         //向瀏覽器返回數(shù)據(jù)
    26.         while (!feof($fp) && $file_count < $file_size) {
    27.             $file_con = fread($fp, $buffer);
    28.             $file_count += $buffer;
    29.             echo $file_con;
    30.         }
    31.         fclose($fp);
    32.     }


    標(biāo)簽:
    最后修改:2025-07-03 13:13:05

    非特殊說明,本博所有文章均為博主原創(chuàng)。

    主站蜘蛛池模板: 瑞昌市| 贡觉县| 靖州| 虞城县| 宜阳县| 武川县| 来凤县| 丰城市| 三明市| 平江县| 大英县| 河北区| 新建县| 西贡区| 策勒县| 武夷山市| 永丰县| 洛浦县| 新邵县| 台东市| 沙洋县| 洪雅县| 花莲市| 永昌县| 密云县| 枝江市| 桃江县| 保德县| 桃园县| 交口县| 湾仔区| 无极县| 高要市| 大兴区| 云林县| 灵璧县| 大邑县| 沁阳市| 方城县| 青阳县| 朝阳县|