gpt4 book ai didi

PHP 在服务器上创建文本文件

转载 作者:行者123 更新时间:2023-11-29 08:45:10 24 4
gpt4 key购买 nike

在我的 php 应用程序中,我想以文本格式创建错误日志,因此尝试这样在我的本地计算机中工作正常

if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
$stringData = "Error Info: ".$mail->ErrorInfo."\t\t";
$stringData .= "Email to reciepient \t Regnumber: ".$RegNo." \t Apllicant Name: ".$ApplicantName." Failed --- end ----";


$fp = fopen($_SERVER['DOCUMENT_ROOT']."/lib/email_errorlog.txt","wb");
fwrite($fp,$stringData);
fclose($fp);

exit;
}

我已经在 PHP Create and Save a txt file to root directory 中看到过讨论但它不适合我。问题是,没有显示错误,但没有创建文本文件。需要在服务器上设置任何权限吗?

最佳答案

您必须确保:

  • 文件夹/lib 存在于文档根目录中
  • 网络服务器进程有权写入该文件夹。

如果您使用您的ftp 帐户创建该文件夹,则网络服务器进程将访问权限。您可以将权限设置为 777,但这样每个人都可以访问。最好将权限设置为 770 并将文件夹的组设置为 Web 服务器组 ID。

关于PHP 在服务器上创建文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12686644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com