Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Team

I having this problem by using my logs from the server. Im sending email as pdf and using function to do using phpmailer. But now the logs show have a problem with line 94 on the application.php. How can i resolve this issue?

What I have tried:

$content = file_get_contents($filenameee);
  $content = chunk_split(base64_encode($content));
   // main header (multipart mandatory)
$headers = "From: ".$from." <".$from.">" . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;
$headers .= "Content-Transfer-Encoding: 7bit" . $eol;
$headers .= "This is a MIME encoded message." . $eol;
   $headers .= "MIME-Version: 1.0\r\n";
   $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

   $subject = "Application Form";

// a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (RFC)
$eol = "\r\n";


// function to send email for attachment using phpmailer
    echo "Starts here..";
    
function send_pdf_to_user(){
   
    if($_REQUEST['action'] == 'pdf_invoice' ){
        
        require('application.php');
        
        require_once('class.phpmailer.php');
    
        $pdf=new PDF_HTML();
        
        $pdf->SetFont('Arial','',11);
        
        $pdf->AddPage();
        

        $text = get_html_message($_REQUEST['Amount'], $_REQUEST['Purpose'], $_REQUEST['Voucher']);
        if(ini_get('magic_quotes_gpc')=='1')
        $text=stripslashes($text);
        $pdf->WriteHTML($text);

        $mail = new PHPMailer(); // defaults to using php "mail()"
        $body = "";
       
        $mail->AddReplyTo("info@agilelimitless.org.za","Test Lernt");
        $mail->SetFrom('ggcobani@gmail.com', 'Test Lernt');
       
        $address = "ongeziwe.gogotye@agilelimitless.org.za";
		
		$mail->AddAddress($address, "ACI Finance");       
        $mail->Subject    = "Application for a Loan";       
        $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
       
        $mail->MsgHTML($body);
        //documentation for Output method here: http://www.fpdf.org/en/doc/output.htm       
        $pdf->Output("Application Loan.pdf","F");
        $path = "application.pdf";
         
        $mail->AddAttachment($path, '', $encoding = 'base64', $type = 'application/pdf');
        global $message;
        if(!$mail->Send()) {
          $message =  "Application for a loan could not be send. Mailer Error: " . $mail->ErrorInfo;
        } else {
          $message = "Application for a loan is sent!";
        }
        
       
    }
}

    echo "after function";
   $to = "Ongeziwe.Gogotya@agilelimitless.org.za";
   $from = $_REQUEST['email'];
   $filenameee = $_FILES['id']['name'];
    $fileName = $_FILES['id']['tmp_name'];
Posted
Updated 3-Mar-23 5:24am
Comments
Richard MacCutchan 3-Mar-23 9:51am    
Look at the error message. Whereever you are trying to load that file from, it is not there.
Gcobani Mkontwana 3-Mar-23 9:53am    
file_get_contents(FASHION SHOW.pdf): failed to open stream: No such file or directory in /home/acifinan/public_html/application.php on line 94. @Richard MacCutchan yes although we dont even get pdf document as attached its chunk in terms of content not even readable

1 solution

The error message is very explicit: the file (or part of the path to it) does not exist, or isn't accessible.

At a guess, the file is local to your computer, and your code is running on the server which has no access to your local file system.
So check the path: identify which computer the file is actually on, and which computer is running the code.

By the looks of it, this is a web app - so a client path will never be directly accessible to PHP code, because that always runs on the server. To get access to it, the user would have to initiate an upload of the file to the server first for security reasons.
 
Share this answer
 
Comments
Gcobani Mkontwana 3-Mar-23 12:25pm    
@OriginalGriff, you shared some light. yes the user does have to upload the document, the content of the format is in html we cant read. How can i fix this issue so a user can be able when uploading the document can easily view pdf as an attachment

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900