Dhira Posted April 15, 2006 Share Posted April 15, 2006 Hi,Say I have a file in a folder;[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]www.domain.com/includes/file.txt[/quote]and I want to move it to [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]www.domain.com/file.txt (i.e.move it to public_html)[/quote]What code do I need to do this? (That will enable it replace a file of the same name if there is one)Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/7471-php-code-to-copy-a-file-from-one-directory-to-another/ Share on other sites More sharing options...
Orio Posted April 15, 2006 Share Posted April 15, 2006 Just use the copy() function to copy the file, and the unlink() function to delete the old file...Orio. Quote Link to comment https://forums.phpfreaks.com/topic/7471-php-code-to-copy-a-file-from-one-directory-to-another/#findComment-27228 Share on other sites More sharing options...
Dhira Posted April 15, 2006 Author Share Posted April 15, 2006 What is the copy() function?ie what is the code I need to do that? Quote Link to comment https://forums.phpfreaks.com/topic/7471-php-code-to-copy-a-file-from-one-directory-to-another/#findComment-27329 Share on other sites More sharing options...
redbullmarky Posted April 16, 2006 Share Posted April 16, 2006 [!--quoteo(post=365161:date=Apr 15 2006, 10:12 PM:name=Dhira)--][div class=\'quotetop\']QUOTE(Dhira @ Apr 15 2006, 10:12 PM) [snapback]365161[/snapback][/div][div class=\'quotemain\'][!--quotec--]What is the copy() function?ie what is the code I need to do that?[/quote]from the manual....[a href=\"http://uk2.php.net/copy\" target=\"_blank\"]http://uk2.php.net/copy[/a][code]copy($source, $dest);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7471-php-code-to-copy-a-file-from-one-directory-to-another/#findComment-27361 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.