zoukankan      html  css  js  c++  java
  • txt文件下载

    $content = '订购日志明细:'.$begin_date.'至'.$end_date;

    if ($detail_list) {
    foreach ($detail_list as $detail) {
    $content .= '手机号:'.$detail['MSISDN'];
    $content .= ' 归属地:全国';
    $content .= ' 歌曲名称:'.$detail['CONTENT_NAME'];
    $content .= ' 业务ID:'.$detail['CONTENT_ID'];

    $biz_type = isset($bussiness_list[$detail['BIZ_TYPE']]) ? (($detail['BIZ_TYPE'] == '02' && $detail['FEE_TYPE'] == '03') ? '开通包月业务' : $bussiness_list[$detail['BIZ_TYPE']]) :'';
    $content .= ' 业务类型:'.$biz_type;
    $biz_type = '';

    $content .= ' 计费触发时间:'.timeStrToDate($detail['TIME_STAMP']);
    $content .= ' 价格(单位:分):'.timeStrToDate($detail['PRICE']);
    }
    }

    $filename = 'logDetil.txt';
    $this->downTxt($filename);
    echo $content;
    $content = '';

    /**
    * 下载文本文件
    */
    function downTxt($filename) {
    header("Content-Type: application/force-download");
    header("Content-Type: application/download");
    header("Content-Transfer-Encoding: binary");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: no-cache");

    Header("Content-type: application/octet-stream");
    Header("Accept-Ranges: bytes");
    Header("Accept-Length: ".filesize($filename). ' bytes');

    Header('Content-Disposition: attachment; filename='.$filename);
    }

    换行的话用"\r\n",必须是双引号才能解析。

  • 相关阅读:
    VS 2017 没有工具栏中没有Report Viewer的解决方案
    数据类型和C#关系对应
    .NET CORE部署各种问题
    .NET CORE AutoMapper使用
    .NET CORE 配置Swagger文档
    window快捷登陆linux的的设置方式(设置ssh的config配置)
    linux安装mongodb并启动
    windows更改DNS设置
    scp的使用
    浏览器缓存机制
  • 原文地址:https://www.cnblogs.com/xingmeng/p/3023607.html
Copyright © 2011-2022 走看看