Jump to content

issue with copy function


suzzane2020

Recommended Posts

Hi,

 

  I have a strange issue here.

I have written a script to make a directory and ten copy a file to that directory.

I have given the directory full prmissions using the chmod function.

 

The directory is created but am not able to copy the file.

 

here is the code

 

if(isset($_POST["reg"]))
{
$brand  = $_POST["brand"];

$file_name = "template1.php";
$file_path = "brand_sites"; 

if(!is_dir("$file_path/$brand")) {mkdir("$file_path/$brand/"); chmod("$file_path/$brand/",0777);}


if(copy("$file_path/$file_name","$file_path/$brand/$file_name"))
       {
          		 	print "Copied"; 
}


}

 

Whats strange is that -if i create a folder manually and give it permissions the file can be copies using the function.

 

could anyone please throw some light on this problem.

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/57639-issue-with-copy-function/
Share on other sites

i dont understand but try to see the error i found

 

if(isset($_POST["reg"]))

{

$brand  = $_POST["brand"];

 

$file_name = "template1.php";

$file_path = "brand_sites";

 

if(!is_dir("$file_path/$brand")) {mkdir("$file_path/$brand/");//error ------ terminator

chmod("$file_path/$brand/",0777);}

 

 

if(copy("$file_path/$file_name","$file_path/$brand/$file_name"))

      {

          print "Copied";

}

 

 

}

 

 

that will kill the if condition

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.