suzzane2020 Posted June 28, 2007 Share Posted June 28, 2007 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 More sharing options...
suzzane2020 Posted June 28, 2007 Author Share Posted June 28, 2007 somebody...anybody ??? Link to comment https://forums.phpfreaks.com/topic/57639-issue-with-copy-function/#findComment-285366 Share on other sites More sharing options...
teng84 Posted June 28, 2007 Share Posted June 28, 2007 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 https://forums.phpfreaks.com/topic/57639-issue-with-copy-function/#findComment-285368 Share on other sites More sharing options...
teng84 Posted June 28, 2007 Share Posted June 28, 2007 oops sorry wrong post Link to comment https://forums.phpfreaks.com/topic/57639-issue-with-copy-function/#findComment-285369 Share on other sites More sharing options...
suzzane2020 Posted June 28, 2007 Author Share Posted June 28, 2007 hmm actually i want to bring to your attention that if i create the folder manually and give it permissions .the same script works great!!!! its only when i use the mkdir and the chmod function. But i need to use them too ??? Link to comment https://forums.phpfreaks.com/topic/57639-issue-with-copy-function/#findComment-285370 Share on other sites More sharing options...
teng84 Posted June 28, 2007 Share Posted June 28, 2007 http://www.php.net/manual/en/function.copy.php#55130 try that one Link to comment https://forums.phpfreaks.com/topic/57639-issue-with-copy-function/#findComment-285372 Share on other sites More sharing options...
pocobueno1388 Posted June 28, 2007 Share Posted June 28, 2007 chmod("$file_path/$brand/",0777); Instead of using "0777", try just "777". chmod("$file_path/$brand/",777); Link to comment https://forums.phpfreaks.com/topic/57639-issue-with-copy-function/#findComment-285373 Share on other sites More sharing options...
suzzane2020 Posted June 29, 2007 Author Share Posted June 29, 2007 ok let me try that Link to comment https://forums.phpfreaks.com/topic/57639-issue-with-copy-function/#findComment-285378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.