• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

annoying php script issue

zimu

Diamond Member
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);
?>
 
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?)
 
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?
 
Back
Top