mkdir()权限被拒绝 - PHP

时间:2017-10-08 09:37:22

标签: php html xml macos macos-sierra

我正在尝试基于HTML表单输入创建XML文档。但是,一旦执行了php,我会得到一个页面: enter image description here

<?php
header('Content-type: text/xml');
$dom = new DOMDocument("1.0","UTF-8");
$customer = $dom->createElement("customer");
$dom->appendChild($customer);

$dir = 'XMLfiles';
if ( !file_exists($dir) ) {
 $oldmask = umask(0);  // helpful when used in linux server  
 mkdir ($dir, 0744);
 }

$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$password = $_POST['password'];
$cust = $dom->createElement("customer");
$customer->appendChild($cust);
$name = $dom->createElement("fname",$fname);
$cust->appendChild($name);
$emailxml = $dom->createElement("Email", $email);
$cust->appendChild($emailxml);
$contactxml = $dom->createElement("Contact", $contact);
$cust->appendChild($contactxml);
$passxml = $dom->createElement("Password", $password);
$cust->appendChild($passxml);
//$dom->saveXML();
$dom->save($dir."/customer.xml");

?>

指出我正确的方向,我将学习它。

谢谢大家!

PS:我在mac上尝试这个(如果在授予权限和东西方面有任何不同)。我是编程的新手,所以请忽略任何与我无关的事情或建议我。

1 个答案:

答案 0 :(得分:0)

刚刚发现苹果支持的帖子解释了添加权限。我刚刚这样做:查看信息 - &gt;文件共享和权限 - &gt;将所有内容都改为读/写。

我现在将结束这个问题。