doujiaochan7317
2017-07-27 19:08
浏览 34
已采纳

如何更改mPDF输出()的根文件夹?

How can I change the root folder of my mPDF Output()?

I need a filename that is taken from a variable and the file should be saved in my folder called "/files". The location for the file should be in a variable like $location =("/location").

Now my output is generating in the root folder.

$sql=mysql_query("SELECT * FROM `client_details` ORDER BY `c_id` DESC LIMIT 1");  

while($data = mysql_fetch_array($sql))   
{ 
    $name=$data['name'];
}

$name_p = $name."-estimation.pdf";
$mpdf->Output($name_p,'F');

图片转代码服务由CSDN问答提供 功能建议

如何更改mPDF 输出()的根文件夹?

我需要一个从变量中获取的文件名,该文件应保存在名为“/ files”的文件夹中。 该文件的位置应该在一个变量中,如 $ location =(“/ location”)

现在我的输出正在根文件夹中生成。

  $ sql = mysql_query(“SELECT * FROM`client_details` ORDER BY`c_id` DESC LIMIT 1”);  
 
而($ data = mysql_fetch_array($ sql))
 {
 $ name = $ data ['name']; 
} 
 
 $ name_p = $ name。“ -  estimate.pdf”;  
 $ mpdf->输出($ name_p,'F'); 
   
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanpi7578 2017-07-27 19:13
    已采纳
    $mpdf->Output("/absolute/path/to/directory/" . $name_p,'F');
    

    or

    $mpdf->Output("relative/path/to/directory/" . $name_p,'F');
    
    点赞 评论
  • douchui4815 2017-07-27 19:20
    $path = __DIR__.'/../../files/'; //til you're at the location of upload 
    /*
    //you can use, will return false if incorrect path
    die(realpath($path to make sure you are at the right level))
    */
    //concatenate file path to your file name 
    $mpdf->Output($path.$name_p,'F');
    
    点赞 评论

相关推荐 更多相似问题