Genesis730 Posted July 5, 2010 Share Posted July 5, 2010 How can I transfer files from one directory to another?? Here's my code, however I get this error... "The second argument to copy() function cannot be a directory in *WAMP Dir*/process.php on line 141" Line 141 is - copy($tempdir, $leaguedir); $tempdir = $_SERVER['DOCUMENT_ROOT']."temp/index.php"; $enddir = $_SERVER['DOCUMENT_ROOT'].$dir; copy($tempdir, $enddir); I planned on doing this several times, one for each file, however if anyone knows how to do the entire directory, that would be awesome! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 5, 2010 Share Posted July 5, 2010 If you look in the comments section of the manual entry for the copy function, there are examples of scripts that copy directories. Ken Quote Link to comment Share on other sites More sharing options...
Genesis730 Posted July 5, 2010 Author Share Posted July 5, 2010 It appears, with the script on http://us2.php.net/copy by nensa at zeec dot biz as if the script is trying to look for the initial and final directory where the script is located. Here is the error Warning: fopen(*WAMP Dir*/temp/) [function.fopen]: failed to open stream: No such file or directory in *WAMP Dir*/process.php on line 141, line 141 is the start of the script "$fsrc = fopen($tempdir,'r');" Any ideas? Quote Link to comment Share on other sites More sharing options...
Genesis730 Posted July 5, 2010 Author Share Posted July 5, 2010 So I think I'm close, now I get a permission error, specifically " [function.fopen]: failed to open stream: Permission denied" here's the code... $fsrc = fopen($tempdir,'r'); $fdest = fopen($leaguedir,'w+'); $len = stream_copy_to_stream($tempdir,$leaguedir); fclose($fsrc); fclose($fdest); return $len; Any ideas? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 5, 2010 Share Posted July 5, 2010 So I think I'm close, now I get a permission error, specifically " [function.fopen]: failed to open stream: Permission denied" here's the code... $fsrc = fopen($tempdir,'r'); $fdest = fopen($leaguedir,'w+'); $len = stream_copy_to_stream($tempdir,$leaguedir); fclose($fsrc); fclose($fdest); return $len; Any ideas? If its a permission problem, then make sure your server allows for such actions through a php script. Quote Link to comment Share on other sites More sharing options...
Genesis730 Posted July 5, 2010 Author Share Posted July 5, 2010 I have it on a WAMP server, so IDK if there's default permissions set on that, if so how would I turn them off and if not, any other ideas?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.