【问题标题】:Create button download codeigniter创建按钮下载codeigniter
【发布时间】:2016-03-18 04:37:06
【问题描述】:

在我看来,我有一个文件:contract_list.php

buttons

<td width="1%" class="remove_tag">';
if($this->green->gAction("P"))
{
    $tr .='<a title="Preview Contract" id="clk_pri" class="clk_pri">
    <img rel="'.$contract['con_id'].'" src="'.site_url('../assets/images/icons/preview.png').'" onclick="preview_contract(event);" style="width:20px;height:20px;"></a>';
}$tr .='</td>

点击上方按钮功能预览

function preview_contract(event){
            //Code here event click
    }

我想下载文件 .pdf .doc 表格文件夹?但是在数据库中命名文件记录。

【问题讨论】:

    标签: php codeigniter pdf download


    【解决方案1】:

    您可以使用 $this->load->helper('download') 为 codiegniter 和 force_download($name, $data) 并在 $name 变量中传递您的文件名。

    public function plaintext() {
            //load the download helper
            $this->load->helper('download');
            //set the textfile's content 
            $data = 'Hello world! Codeigniter rocks!';
            //set the textfile's name
            $name = 'filedownload.txt';
            //use this function to force the session/browser to download the created file
            force_download($name, $data);
        }
    

    查看全文,可以参考以下网址

    http://code.runnable.com/Uha2YpCDyMQpAAJi/download-file-using-codeigniter

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-09
      • 1970-01-01
      相关资源
      最近更新 更多