zoukankan      html  css  js  c++  java
  • PHP如何生成word并下载

    <?php 


    //获取1.html文档的内容(包括html代码)
    $result = file_get_contents('./1.html');
    echo "$result"; 

    // /////////////////////保存///////////////////////////
    //打开缓冲区 
    ob_start(); 

    //指示响应可以被任何缓存区缓存
    header("Cache-Control: public");

    //设置一个下载类型 
    Header("Content-type: application/octet-stream");

    //可以请求网页实体的一个或者多个子范围字段 
    Header("Accept-Ranges: bytes"); 

    //判断浏览器类型
    if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE')) { 
     header('Content-Disposition: attachment; filename=test.doc'); 
    }else if (strpos($_SERVER["HTTP_USER_AGENT"],'Firefox')) { 
     Header('Content-Disposition: attachment; filename=test.doc'); 
    else { 
     header('Content-Disposition: attachment; filename=test.doc'); 


    //不使用缓存
    header("Pragma:no-cache"); 
    //过期时间 
    header("Expires:0"); 
    //输出全部内容到浏览器 
    ob_end_flush(); 

  • 相关阅读:
    xiaota-banzhuren-login.vue-重置密码
    xiaota-banzhuren-login.vue
    xiaota-global-index
    xiaota-router-index
    tab表格嵌套tab表格
    xiaota-selectarr
    xiaota-getlunardate
    xiaota-format
    xitaota-DataTime
    xiaota-axioslmport
  • 原文地址:https://www.cnblogs.com/ymdphp/p/10879518.html
Copyright © 2011-2022 走看看