PHP-fopen:无法打开流:权限被拒绝
我是PHP新手。我计划创建文件夹,子文件夹,到该文件取决于用户输入 已成功创建文件夹和子文件夹 最后,我尝试创建一个显示以下错误的文件 fopen(上载/localhost/hrms):无法打开流:权限被拒绝 在第205行的C:\xampp\htdocs\ssspider\index.php中 我的代码是:PHP-fopen:无法打开流:权限被拒绝,php,file,url,curl,fopen,Php,File,Url,Curl,Fopen,我是PHP新手。我计划创建文件夹,子文件夹,到该文件取决于用户输入 已成功创建文件夹和子文件夹 最后,我尝试创建一个显示以下错误的文件 fopen(上载/localhost/hrms):无法打开流:权限被拒绝 在第205行的C:\xampp\htdocs\ssspider\index.php中 我的代码是: $dir = "http://localhost:8080/hrms/index.php"; //make directory $directoryForServer = "upload"
$dir = "http://localhost:8080/hrms/index.php";
//make directory
$directoryForServer = "upload";
$directoryForClient = $directoryForServer."/".$host."";
mkdir($directoryForClient);
$splitePath = explode("/", $folderPath);
$folderPath1 = $directoryForClient;
for($x = 1; $x <= (count($splitePath)-1) ; $x++)
{
$folderPath1 = $folderPath1."/".$splitePath[$x];
echo "<br>".$folderPath1." - successfully created<br>";
mkdir($folderPath1);
}
writefile($folderPath1);
function writefile($dir)
{
if( is_dir($dir)){
echo $dir;
$myFile = fopen($dir,"w");
if($myFile)
{
fwrite($myFile, $returned_content);
}
fclose($myFile);
}
}
$dir=”http://localhost:8080/hrms/index.php";
//制作目录
$directoryForServer=“upload”;
$directoryForClient=$directoryForServer./“$host.”;
mkdir($directoryForClient);
$splitePath=explode(“/”,$folderPath);
$folderPath1=$directoryForClient;
对于($x=1;$x因为您打开了一个目录,fopen函数只需打开文件即可。您的代码中充满了错误,请参考以下内容:
<?php
//make directory
$host = "aa"; //define $host variable
$directoryForServer = "upload";
$directoryForClient = $directoryForServer."/".$host."";
@mkdir($directoryForClient);
$splitePath = explode("/", $directoryForClient);
$folderPath1 = $directoryForClient;
for($x = 1; $x <= (count($splitePath)-1) ; $x++)
{
$folderPath1 = $folderPath1."/".$splitePath[$x];
echo "<br>".$folderPath1." - successfully created<br>2";
@mkdir($folderPath1);
}
writefile($folderPath1);
function writefile($dir)
{
if( is_dir($dir)){
echo $dir;
$myFile = fopen("upload/aa.txt","w");
if($myFile)
{
$returned_content = "hello world"; //define variable and his content before write to file.
fwrite($myFile, $returned_content);
}
fclose($myFile);
}
}
因为您打开了一个目录,fopen函数只需打开文件。您的代码中充满了错误,请参考以下内容:
<?php
//make directory
$host = "aa"; //define $host variable
$directoryForServer = "upload";
$directoryForClient = $directoryForServer."/".$host."";
@mkdir($directoryForClient);
$splitePath = explode("/", $directoryForClient);
$folderPath1 = $directoryForClient;
for($x = 1; $x <= (count($splitePath)-1) ; $x++)
{
$folderPath1 = $folderPath1."/".$splitePath[$x];
echo "<br>".$folderPath1." - successfully created<br>2";
@mkdir($folderPath1);
}
writefile($folderPath1);
function writefile($dir)
{
if( is_dir($dir)){
echo $dir;
$myFile = fopen("upload/aa.txt","w");
if($myFile)
{
$returned_content = "hello world"; //define variable and his content before write to file.
fwrite($myFile, $returned_content);
}
fclose($myFile);
}
}
可能重复但该文件夹为空。任何想法!可能重复但该文件夹为空。任何想法!