Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-fopen:无法打开流:权限被拒绝_Php_File_Url_Curl_Fopen - Fatal编程技术网

PHP-fopen:无法打开流:权限被拒绝

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"

我是PHP新手。我计划创建文件夹,子文件夹,到该文件取决于用户输入

已成功创建文件夹和子文件夹

最后,我尝试创建一个显示以下错误的文件

fopen(上载/localhost/hrms):无法打开流:权限被拒绝 在第205行的C:\xampp\htdocs\ssspider\index.php中

我的代码是:

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

可能重复但该文件夹为空。任何想法!可能重复但该文件夹为空。任何想法!