Codeigniter将Word文件下载到特定文件夹

时间:2019-04-10 06:59:29

标签: php codeigniter download

我想在我的特定项目目录中下载Word文件。我的代码正在运行,并且还下载了Word文件。 Word文件在下载路径中下载。但我希望将该文件下载到我的特定项目目录中。请为我提供解决方案。我的代码将在以下情况下显示:

public function download_preshipment_word()
{
    $base_url=$this->config->item('base_url');
    $led_id = $this->uri->segment(3); 
    $Query="where ledger_id=$led_id";  
    $data["sam_preshipment_detail"]=$this->insert->Select('sam_preshipment',$Query);     
    $sam_preshipment_info=$data["sam_preshipment_detail"][0];
    //print_r($sam_preshipment_info);exit();
    header("Content-type: application/vnd.ms-word");  
    header("Content-Disposition: attachment;Filename=".rand().".doc");  
    header("Pragma: no-cache");  
    header("Expires: 0");   
        $output=  '
        <!DOCTYPE html>
            <html lang="en"> 
              <head>
                <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">     
                <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
                <title>
                  '.$sam_preshipment_info->pre_ship_id.'
                </title>
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
                <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,700,900" rel="stylesheet" type="text/css">
                <style> 

                    @media print {
                    * {
                        color: #000 !important;
                        text-shadow: none !important;
                        background: transparent !important;
                        box-shadow: none !important;
                    }

                    .wrapper{
                        border: 3px solid #333 ! important;
                    }      

                    table,tr,td,th
                    {
                      border: none;
                      border-collapse: collapse;
                      padding:5px 10px;
                      margin-bottom:1em;
                      font-size: 13.5px;      
                      display: inline-block;              
                    }       
                    #table table,#table tr,#table td,#table th{
                        border: 1px solid #000 !important;  
                        text-align:center;
                    }       
                    b,strong{
                        font-weight:bold;
                    }
                    .tb_center table {
                        margin: 0 auto;
                    } 
                    tr td:last-child{
                        text-align: justify;
                    }
                </style>
              </head>
              <body class="sidebar-icon-only"> 

                <div class="container">
                    <div class="row">               
                        <div class="col-xs-12"> 
                            <div class="wrapper">           
                                <table class="table" style="padding-top: -100px !important;">
                                    <tbody>
                                        <tr>
                                            <th colspan="3" align="center">
                                                <img src="'.$base_url.'themes/frontend/images/sam_header.jpg" height=100 width="450">
                                            </th> 
                                        </tr>
                                    </tbody>
                                </table><br><br>
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <th colspan="2" align="left">
                                          <p>
                                            Report No : '.$sam_preshipment_info->pre_ship_id.'
                                          </p>
                                        </th>
                                        <th align="right">
                                            <p style="text-align: right;">
                                                '.date("d.m.Y",strtotime($sam_preshipment_info->joinon)).'
                                            </p>
                                        </th>
                                    </tr>  
                                </tbody>
                            </table><br><br>
                            <table class="table" style="margin-left:0px;">
                            <tbody> 
                            <tr>
                                <th colspan="3" align="center"><h4><u><b>PRE-SHIPMENT SURVEY REPORT</b></u></h4><br></th>
                            </tr>';  

                             $output .='<tr>
                                 <td colspan="3">
                                <label style="text-align: justify;">At the request of <b style="font-weight: bold;">M/s.';

                                    $this->db->where('cid',$sam_preshipment_info->customer);
                                    $clients=$this->db->get('clients')->row();

                                     $output .=' '.$clients->name.', '.$clients->location.';


                                </b>, We did attend a survey on the external condition of
                                    the cargo detailed below and supervised the loading of cargo into <b style="font-weight: bold;">'.$sam_preshipment_info->cargo.'</b> reefer container no.  <b>'.$sam_preshipment_info->container_no.'.</b><br> </label>     
                                </td>
                             </tr> 

                            <tr>
                                <td colspan="3"><B>We now report as below:</B><br>
                                </td>
                            </tr>
                            <tr>
                                 <th colspan="3"><b style="text-align: left;border-bottom: 2px solid #000;">
                                  INVOICE PARTICULARS</b><br>
                                </th>
                            </tr>';


                            </tbody>
                        </table> 
                        </div>           
                      </div>
                  </div>
              </div>  
              </body> 
            </html>';   

            echo $output;   
} 

0 个答案:

没有答案