Hey all. I have a simple script that allows a user to specify the name of a directory to be created. The script creates the directory and then is supposed to copy a specific file to that directory however when I try to run the script I get the following error:
Warning: copy(/home/content/f/t/p/ftpakadmin/html/gallery/testgall/): failed to open stream: Is a directory in /home/content/f/t/p/ftpakadmin/html/admin/gallery/gallery-add-save.php on line 28
Here's the script:
?
//Get the form information.
$name = $_POST['name'];
$gdate = $_POST['gdate'];
$directory = strtolower($_POST['gname']);
//Make sure the directory was properly specified.
if(isset($directory)){
if(strlen($directory) == 8){
//Create the directory
if(!mkdir("/home/content/f/t/p/ftpakadmin/html/gallery/".$directory, 0777)){
echo "Could not make directory, please click <a href='javascript:history.go(-1);'>here</a> to try again.";
exit();
}
//Copy the necessary files
if(!copy("/home/content/f/t/p/ftpakadmin/html/gallery/bolGallery.php", "/home/content/f/t/p/ftpakadmin/html/gallery/".$directory."/")){
echo "Could not copy files, please click <a href='javascript:history.go(-1);'>here</a> to try again.";
exit();
}
//Create the path to store in the database
$path = "./".$directory."/bolGallery.php";
}else{
echo "Your directory must be 8 characters in length. Click <a href='javascript:history.go(-1);'>here</a> to try again.";
}
}
?>
Now it makes the directory no problem but hangs at copying the files. I'm stumped. I've tried with and without the trailing slash at the end of the destination directory.
TIA!