annoying php script issue

zimu

Diamond Member
Jun 15, 2001
6,209
0
0
this code used to work but for some weird reason its been broken since upgrade to php 5 and i just can't troubleshoot it.

basically, all it does it get a listing of files from dir1 and moves all the files to dir2.

the ftp account is fine, it logs in ok based on my debugging. the error it yields is in the RNFR command for ftp where it complaints there's an error, although i don't see why!

<?
$dir1 = 'home/dir1'; //directory move files from
$dir2 = 'home/dir2'; //directory move files to

//establish ftp connection
$conn_id = ftp_connect("hostname");
$login_result = ftp_login($conn_id, "user", "password");


//builds lists of files to move. they're stored as home/dir1/<filename>
$filestomove = ftp_nlist($conn_id, $dir1);


//foreach command that moves each file into dir2
foreach($filestomove as $file)
{
$filesfrom = $dir1.$file; // i tried this as just $file too, no luck
$filesto = $dir2.$file;
echo "Moving ".$file;
echo "<br>";
ftp_rename($conn_id, $filesfrom, $filesto);
}

//closes ftp session
ftp_close($conn_id);
?>
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
As a sanity check, did you try doing this manually on the target server with an FTP program or from a shell window?

(That is, make sure that the server hasn't stopped supporting RNFR between folders?)
 

zimu

Diamond Member
Jun 15, 2001
6,209
0
0
davesimmons:
ftp> rename
(from-name) thefile.tar.gz
(to-name) ../dir2/thefile.tar.gz
350 Ready for RNTO.
250 Rename successful.


so rename definitely works.


blahblah99 - not sure what you meant?