php – file_put_contents:无法打开流,没有这样的文件或目录

我正在尝试使用dompdf将表单保存到易于阅读的.pdf文件中,我的处理脚本如下所示.我收到错误警告:file_put_contents(/files/grantapps/NAME0.pdf)[function.file-put-contents]:无法打开流:/ home / username / public_html / subdir / apps /中没有这样的文件或目录第39行的dompdf / filename.PHP.(第39行是我的完整脚本中的最后一行.)我不知道如何解决这个问题.

allow_url_fopen已启用,我已经尝试了各种文件路径,包括完整目录(/ home / username / public_html / subdir / files / grantapps /)以及下面代码中的内容,但没有任何效果.

require_once("dompdf_config.inc.PHP");
date_default_timezone_set('America/Detroit');

$html = 'code and whatnot is here';

$name = str_replace(" ", "", $_POST['form2name']);
$i = 0;
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
while(file_exists("files/grantapps/" . $name . $i . ".pdf")) {
    $i++;
}
file_put_contents("files/grantapps/" . $name . $i . ".pdf", $dompdf->output());

解决方法:

目标文件夹路径肯定存在问题.

您的上述错误消息显示,它希望将内容放入目录/ files / grantapps /中的文件,这将超出您的vhost,但系统中的某个位置(请参阅前导绝对斜杠)

你应该仔细检查:

>目录/ home / username / public_html / files / grantapps /是否真的存在.
>包含你的循环和你的file_put_contents-Statement绝对路径/ home / username / public_html / files / grantapps /

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...