Foros del Web » Programando para Internet » PHP »

error en enviar pdf phpmailer

Estas en el tema de error en enviar pdf phpmailer en el foro de PHP en Foros del Web. Hola a todos estoy creando un archivo pdf con tcpdf y despues de crearlo enviarlo por phpmailer y me sale este error. Código PHP: Warning: fopen(example_048.pdf) [function.fopen]: failed to open stream: Permiso denegado in /opt/lampp/htdocs/sisco/vercotizaciones/tcpdf/tcpdf.php on line 5929 ...
  #1 (permalink)  
Antiguo 24/06/2010, 09:10
 
Fecha de Ingreso: mayo-2010
Mensajes: 153
Antigüedad: 13 años, 11 meses
Puntos: 0
Exclamación error en enviar pdf phpmailer

Hola a todos estoy creando un archivo pdf con tcpdf y despues de crearlo enviarlo por phpmailer y me sale este error.

Código PHP:
Warning: fopen(example_048.pdf) [function.fopen]: failed to open stream: Permiso denegado in /opt/lampp/htdocs/sisco/vercotizaciones/tcpdf/tcpdf.php on line 5929
TCPDF ERROR: Unable to create output file: example_048.pdf


//
codigo que utilizo

<?php
//============================================================+
// File name   : example_003.php
// Begin       : 2008-03-04
// Last Update : 2009-09-30
// 
// Description : Example 003 for TCPDF class
//               Custom Header and Footer
// 
// Author: Nicola Asuni
// 
// (c) Copyright:
//               Nicola Asuni
//               Tecnick.com s.r.l.
//               Via Della Pace, 11
//               09044 Quartucciu (CA)
//               ITALY
//               www.tecnick.com
//               [email protected]
//============================================================+

/**
 * Creates an example PDF TEST document using TCPDF
 * @package com.tecnick.tcpdf
 * @abstract TCPDF - Example: Custom Header and Footer
 * @author Nicola Asuni
 * @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - [email protected]
 * @link http://tcpdf.org
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
 * @since 2008-03-04
 */

require_once('tcpdf/config/lang/eng.php');
require_once(
'tcpdf/tcpdf.php');
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {
    
//Page header
    
public function Header() {
        
// Logo
        
$this->Image(K_PATH_IMAGES.'logo.jpg'15830);
        
// Set font
        
$this->SetFont('helvetica''B'10);
        
// Move to the right
        
$this->Cell(80);
        
// Title
        
$this->Cell(3010'F03-003'00'C');
        
// Line break
        
$this->Ln(20);
    }
    
    
// Page footer
    
public function Footer() {
        
// Position at 1.5 cm from bottom
        
$this->SetY(-25);
        
// Set font
        
$this->SetFont('helvetica''I'8);
            
// Title
    
$this->Cell(00'Direccion:Av.37B No. 38A-12 Itagui-Colombia - PBX:(574)370 47 00 -Fax(574) 281 73 27 - 372 78 52'00'C');
        
// Page number
        
$this->Ln(4);
        
$this->Cell(00'WEB PAGE: www.cisealco.com - EMAIL: [email protected]'00'C');
        
$this->Ln(4);
        
$this->Cell(00'Revision 03 05-04'00'C');
        
$this->Ln(2);
        
$this->Cell(010'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 00'C');
    }
}

// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue'UTF-8'false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 003');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGOPDF_HEADER_LOGO_WIDTHPDF_HEADER_TITLEPDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN''PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFTPDF_MARGIN_TOPPDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUEPDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 

//set some language-dependent strings
$pdf->setLanguageArray($l); 

// ---------------------------------------------------------

// set font
$pdf->SetFont('helvetica'''8);

// add a page
$pdf->AddPage();

// ---------------------------------------------------------

// set font

$pdf->SetFont('times''B'12);
$pdf->MultiCell(00'Solicitud No '.$cod.''0'C'01''''true0);

// -----------------------------------------------------------------------------
$pdf->SetFont('helvetica'''9);
$tbl = <<<EOD
<br />
<br />
<br />
<table width="530" border="1" align="left">
  <tr>
    <td width="83"><strong>Fecha</strong></td>
    <td width="124">$fechasolicitud</td>
    <td width="40"><strong>Ciudad</strong></td>
    <td colspan="3" width="276">$Mciudad</td>
  </tr>
  <tr>
    <td width="83"><strong>Empresa</strong></td>
    <td colspan="5" width="440">$Mempresa</td>
  </tr>
  <tr>
    <td width="83"><strong>Nombre contacto</strong></td>
    <td width="124">$contacto</td>
    <td width="42"><strong>Email</strong></td>
    <td width="124">$email</td>
    <td width="75"><strong>Tel&eacute;fono</strong></td>
    <td width="75">&nbsp;</td>
  </tr>
  <tr>
    <td width="83"><strong>Fax</strong></td>
    <td width="124">$fax</td>
    <td width="42"><strong>Direcci&oacute;n</strong></td>
    <td width="274" colspan="3">$direccion</td>
  </tr>
  <tr>
    <td width="83"><strong>Precios</strong></td>
    <td width="124">SEALCO S.A.</td>
    <td width="42"><strong>Moneda</strong></td>
    <td width="124">Pesos Colombianos</td>
    <td width="75"><strong>Iva:</strong></td>
    <td width="75">16%</td>
  </tr>
</table>
EOD;

$pdf->writeHTML($tbltruefalsefalsefalse'');

// ---------------------------------------------------------


// -----------------------------------------------------------------------------
$pdf->SetFont('helvetica'''9);
$tbl = <<<EOD
<table border="1" align="left">
  <tr>
    <td width="20"><strong>Item</strong></td>
    <td width="22"><strong>Cant</strong></td>
    <td width="290"><strong>Descripci&oacute;n</strong></td>
    <td width="70"><strong>Tiempo entrega</strong></td>
    <td width="60"><strong>Vlr.Unit</strong></td>
    <td width="60"><strong>Vlr.Total</strong></td>
  </tr>
  $mailContents
    <tr>
    <td colspan="6" width="522"></td>
  </tr>
  <tr>
    <td width="20"></td>
    <td width="20"></td>
    <td width="295"></td>
    <td width="63"></td>
    <td width="62"><strong>SUBTOTAL</strong></td>
    <td width="62" align="right">$ $subtotalfort</td>
  </tr>
   <tr>
    <td width="20"></td>
    <td width="20"></td>
    <td width="295"></td>
    <td width="63"></td>
    <td width="62"><strong>IVA 16%</strong></td>
    <td width="62" align="right">$ $ivafort</td>
  </tr>
   <tr>
    <td width="20"></td>
    <td width="20"></td>
    <td width="295"></td>
    <td width="63"></td>
    <td width="62"><strong>TOTAL</strong></td>
    <td width="62" align="right">$ $totalfort</td>
  </tr>
   <tr>
    <td width="62">Observaciones</td>
    <td width="460">$obs</td>
  </tr>
</table>
EOD;

$pdf->writeHTML($tbltruefalsefalsefalse'');
// ---------------------------------------------------------


// -----------------------------------------------------------------------------
$pdf->SetFont('helvetica'''9);
$tbl = <<<EOD
<br />
<br />
<br />
<table width="520" border="0" align="left">
  <tr>
    <td width="85">Validez de la oferta</td>
    <td width="230"><u>$validezof</u></td>
    <td width="90">Condiciones de pago</td>
    <td width="115"><u>La usual</u></td>
  </tr>
    <tr>
    <td colspan="4" width="520">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4" width="520" align="center">      _________________________________</td>
  </tr>
  <tr>
    <td colspan="4" width="520" align="center">Aprobaci&oacute;n</td>
  </tr>
</table>
EOD;
$pdf->writeHTML($tbltruefalsefalsefalse'');
//$pdf->Output('example_048.pdf', 'I');


$filename "example_048.pdf";
// use for Upload folder >>>>>>>>>>>>>>>>>
$pdf->Output("../archivos/" $filename,"F"); 
$pdf->Output($filename"F"); 




























require 
"../PhpMailer/class.phpmailer.php";
$mail = new phpmailer();
$mail->PluginDir "../PhpMailer/";
$mail->Mailer "smtp";
$mail->Host "190.145.15.166";
$mail->SMTPAuth true;
$mail->Username "[email protected]"
$mail->Password "websealco";
$mail->From "[email protected]";
$mail->FromName "www.cisealco.com";
$mail->Timeout=15;
//$mail->AddReplyTo("[email protected]","sdfsdf");
$mail->AddAddress("[email protected]");
//$mail->AddReplyTo("[email protected]","Nombre Apellido"); 
//$mail->AddReplyTo('[email protected]', 'sdfsdf');

//A quien
//$mail->AddReplyTo("[email protected]", "Replies for my site");
$mail->Subject "Cotizacion numero uno";

$mail->Body ="<meta http-equiv='content-Type' content='text/html; charset=iso-8859-1' /> 
<style type='text/css'>
<!--

-->
</style>
Esta es una cotizacion
"
;
$mail->IsHTML(true);
$mail->AddAttachment("../archivos/example_048.pdf""archivo.pdf");
$mail->Send();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Encuesta Sealco</title>
<link rel="stylesheet" type="text/css" href="../../master.css"/>
</head>
<body>
</body>
</html>
  #2 (permalink)  
Antiguo 31/10/2010, 12:29
 
Fecha de Ingreso: septiembre-2009
Mensajes: 17
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: error en enviar pdf phpmailer

no se mucho, pero el mensaje dice permiso denegado
tenes permiso de lectura y escitura? otra cosa no se
  #3 (permalink)  
Antiguo 31/10/2010, 20:58
 
Fecha de Ingreso: diciembre-2008
Mensajes: 102
Antigüedad: 15 años, 4 meses
Puntos: 1
Respuesta: error en enviar pdf phpmailer

despues de creado tienes que utilizar esta funcion chmod para aplicarle a permisos de de lectura y escritura al script para que pueda hacer uso de el archivo generado.
__________________
█ Luis Toscano - CodeMaster
Codigolandia.com
Foros Del Hosting
  #4 (permalink)  
Antiguo 01/11/2010, 20:42
 
Fecha de Ingreso: abril-2008
Ubicación: Barcelona
Mensajes: 99
Antigüedad: 16 años
Puntos: 0
Respuesta: error en enviar pdf phpmailer

Por curiosidad el que tiene que tener los permisos de escritura es el archivo php, la carpeta o el archivo pdf???

Etiquetas: enviar, pdf, phpmailer
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:47.