Jump to content

Copy files in one directory to another?


Genesis730

Recommended Posts

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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

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.