2
PHP Warning:  file_put_contents(http://lendersmatch.ca/wp-content/uploads/deals/deal1.pdf): failed to open stream: HTTP wrapper does not support writeable connections in /home/t21jv08zz60b/public_html/wp-content/plugins/mortgage/fpdf181/fpdf.php on line 1023 
[27-Jan-2018 11:24:20 UTC] PHP Fatal error:  Uncaught Exception: FPDF error: Unable to create output file: http://lendersmatch.ca/wp-content/uploads/deals/deal1.pdf in

My Code:

$filename=$upload_path.'deals/deal'.$page->id.'.pdf';
ob_clean();
$pdf->Output('F',$filename);

FPDF:

if(!file_put_contents($name,$this->buffer))
    $this->Error('Unable to create output file: '.$name);
    break;
3

$name apparently contains a URL. That won't work. Set it to a local path, as you did with $filename:

    $upload_dir = wp_upload_dir();
    $filename = $upload_dir["basedir"] . '/deals/deal' . $page->id . '.pdf';
  • I am passing $filename variable to function as $name. So what you mean by setting local path as $upload_path already url – Muhammad Muazzam Jan 27 '18 at 11:45
  • Right, if $upload_path is the URL, that explains it. Yes, set a local path and it will work. – janh Jan 27 '18 at 11:47
  • Please show me code to set it as local path – Muhammad Muazzam Jan 27 '18 at 11:48
  • Your suggested edit was pretty much it. Just keep in mind that most paths WP will return do not have a trailing slash. – janh Jan 27 '18 at 12:12
-3

You should first open public_html folder on 000wenhostapp.com and open .htaccess file add only one line of code :

php_flag output_buffering on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.