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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.