无法使用FPDF将pdf文件写入上传目录

时间:2018-01-27 作者:Muhammad Muazzam

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
我的代码:

$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;

2 个回复
最合适的回答,由SO网友:janh 整理而成

$name 显然包含URL。那行不通。将其设置为本地路径,就像使用$filename:

    $upload_dir = wp_upload_dir();
    $filename = $upload_dir["basedir"] . \'/deals/deal\' . $page->id . \'.pdf\';

SO网友:SaHiL ShiKalgar

您应该首先打开000wenhostapp上的public\\u html文件夹。com并打开。htaccess文件仅添加一行代码:

php_flag output_buffering on

结束