Jump to content


Photo

PHP code to copy a file from one directory to another?


  • Please log in to reply
3 replies to this topic

#1 Dhira

Dhira
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 15 April 2006 - 11:26 AM

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.

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 15 April 2006 - 12:39 PM

Just use the copy() function to copy the file, and the unlink() function to delete the old file...

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Dhira

Dhira
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 15 April 2006 - 09:12 PM

What is the copy() function?

ie what is the code I need to do that?

#4 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 16 April 2006 - 12:34 AM

[!--quoteo(post=365161:date=Apr 15 2006, 10:12 PM:name=Dhira)--][div class=\'quotetop\']QUOTE(Dhira @ Apr 15 2006, 10:12 PM) View Post[/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]

copy($source, $dest);

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users