【发布时间】:2014-11-10 17:38:00
【问题描述】:
我正在开发一个带有php 和mysql 和dompdf 的网站,在我的一种形式中,我有一个按钮,该按钮必须生成一个.pdf 文件,然后通过发送电子邮件。 (在我的本地主机上,它可以生成pdf文件,但不发送电子邮件。在我的网络服务器上,我无法创建pdf,但发送电子邮件......)
我看到的消息是:
Warning: file_put_contents(C:/Inetpub/vhosts/.../dompdf/lib/fonts/log.htm) [function.file-put-contents]: failed to open stream: Permission denied in C:\Inetpub\vhosts\...\dompdf\include\dompdf.cls.php on line 864
//the mistake in in the `dompdf` class
Warning: file_put_contents(pdf/pdfgenerados/cotizacion.pdf) [function.file-put-contents]: failed to open stream: Permission denied in C:\Inetpub\vhosts\...\list.php on line 116
这是我的代码:
$codigoHTML=utf8_decode($codigoHTML);
$dompdf=new DOMPDF();
$dompdf->load_html($codigoHTML);
ini_set("memory_limit","128M");
$dompdf->render();
$pdf = $dompdf->output();
file_put_contents("pdf/pdfgenerados/cotizacionnueva.pdf", $pdf);
echo "Cotización generada";
//<<-------------- Send by email------------>>>
$fileat = "pdf/pdfgenerados/cotizacionnueva.pdf";
$fileat_type="pdf";
$fileatname= "Cotización.pdf";
$emailfrom="my-email@hotmail.es";
$emailsubject="Cotización";
$emailmessage="------------ Here you have the pdf file... have a nice day";
$emailto="other_e-mail@gmail.com";//
$headers = "From: $emailfrom";
$file = fopen($fileat,'rb');
$data = fread($file,filesize($fileat));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$data = chunk_split(base64_encode($data));
$data . "nn --{$mime_boundary}--n";
$ok = @mail($emailto, $emailsubject, $emailmessage, $headers);
if($ok) {
echo " <br/><font face=verdana size=2>The file was successfully sent!</font>";
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}
我收到了电子邮件。但我没有收到pdf。文件
我能做什么???
【问题讨论】: