Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to copy a file on an FTP server 1

Status
Not open for further replies.

lhuegele

IS-IT--Management
Jan 24, 2002
886
US
I'm looking for a simple PHP script that will take 1 file on an FTP server and copy it to a different file name, overwriting that file if it already exists, and I just want it to do that whenever I run the script.

Sorry I'm new to PHP but this would be very useful to me if someone has the answer.

Thanks!
 
You mean this is on a remote FTP server to where the script is located?

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
Oh sorry, no, the script will reside on the same server (and in the same folder) as the files in question...It's an externally hosted web server for my side hobby.

Thanks,
 
<?php
$file = 'example.txt';
$newfile = 'example.txt.bak';

if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
?>

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
it came from the PHP manual :)

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
DOH! Guess I should get that and read it then! At least I did say I was a noob! Hehehe....

Thanks again!
 
a google search for something like "PHP move file" will turn up results from the manual and heaps of other sources. use "PHP" and almost any question and you are almost certain to get an answer.

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top