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

I need your help, i am getting a message when i try to open pdf document says failed to load a pdf document

"
Expected: application/pdf (.pdf); found: text/plain (.txt)
"

What I have tried:

$filenameee = $_FILES['id']['name'];

// main header (multipart mandatory)
   $headers = "From: ".$fromname." <".$fromemail.">" . $eol;
   $headers .= "MIME-Version: 1.0" . $eol;
   $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;
   $headers .= "Content-Transfer-Encoding: binary";
   $headers .= "This is a MIME encoded message." ;
    $headers .="Content-Length:  . filesize($filenameee)";
    $headers .="Accept-Ranges: bytes" ;
    @readfile($filenameee);


	// message
  //$body = "--" . $separator . $eol;
  $body .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol;
  $body .= "Content-Transfer-Encoding: binary" . $eol;
  $body .= $message . $eol;
	// attachment
 $body .= "--" . $separator . $eol;
 $body .= "Content-Type: application/pdf; name=\"" . $filenameee . "\"" . $eol;
 $body .= "Content-Transfer-Encoding: binary" . $eol;
 $body .= 'Content-Disposition: inline; $filenameee="' . $filenameee . '"';
$body .= $content . $eol;

$body .= "</tbody></table>";
Posted
Comments
Richard MacCutchan 9-Mar-23 11:12am    
Probably because the document is not where you think it is. But without considerably more detail it is difficult to suggest antything useful.
Gcobani Mkontwana 9-Mar-23 11:24am    
@Richard MacCutchan it says when i click the document from the email Expected: application/pdf (.pdf); found: text/plain (.txt). Then after failed to load the document.

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