如何使用TCPDF将pdf保存在共享文件夹中

时间:2014-11-25 12:25:34

标签: php pdf tcpdf

我正在尝试将PDF保存在共享文件夹中。但它给了我错误。我手动检查路径是否正确。但它的权利。但我仍然无法生成PDF。

这是我的代码

<?php
$file = "//ADMIN/testsor/SORPDF.csv"; 
$handle = fopen($file,"r"); 
$data= fgetcsv($handle); 
//print_r($data);exit; 
$filename="Test.pdf";
$filepath="\\\\ADMIN\\testsor\\pdf"; 
require_once('tcpdf_include.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->setFooterData(array(0,64,0), array(0,64,128));

if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->AddPage();
$pdf->SetFont('times', '',11);
$pdf->setPage(1, true);
$txt = '
<table cellpadding="1" border="1" cellspacing="0" width="100%" class="main">
<tr><td class="cen">&nbsp;</td><td style="padding-right:7px" align="right"><strong>Signature</strong> </td><td colspan="3" align="center"  height="50px"><img src="'.$data[0].'" height="20px" width="100px" >
</td></tr>
<tr><td class="cen">&nbsp;</td><td style="padding-right:7px" align="right"><strong>Fitter`s Signature</strong> </td><td colspan="3" align="center" height="50px"><img src="'.$data[1].'" height="20px" width="100px" >
</td></tr>
</table>
 ';

$pdf->writeHTML($txt,1,null,null,null,null);
$fileNL = $filepath."\\".$filename;
$pdf->Output($fileNL,'F');

?>

错误

TCPDF ERROR: Unable to create output file: \\ADMIN\testsor\pdf\test.pdf

5 个答案:

答案 0 :(得分:1)

在运行脚本时,请确保未在任何位置打开文件 \ ADMIN \ testsor \ pdf \ test.pdf 。如果它在其他地方打开,则TCPDF无法打开它。

答案 1 :(得分:0)

你有写作的必要权限吗? 你可以这样改变它 chmod -R 0777 / pdf

答案 2 :(得分:0)

如果这是共享文件夹,请联系该文件夹所属的计算机/服务器的管理员/所有者,以便为您提供对共享文件夹的读写权限

答案 3 :(得分:0)

我解决了这个问题。可能对其他人也有帮助。 这里的问题是它没有在共享文件夹中保存pdf。 我为所有用户共享了此文件夹,并且还提供了完全访问权限。但它仍然没有用。 所以我意识到它与我在“文件夹”中检查的安全性有关 - &gt; RightClick-&gt; Property-&gt; Advance share folder-&gt; Security.I发现这里有'everyone'选项(即在share-&gt; group / username中添加) )没有添加。所以我添加了然后它的工作。

答案 4 :(得分:0)

您已在服务器中授予权限。

ADMIN / testsor(文件夹) - &gt;右键单击 - &gt;属性 - &gt;安全 - &gt;编辑 - &gt; {选择用户} - &gt;允许完全控制检查 - &gt;好的

再试一次