Xodus989 Posted August 4, 2007 Share Posted August 4, 2007 I wrote this script earlier, and it was working, but I found out it wasn't naming the files right, so I fixed that, and when I upload it back to the server and tested it, it doesn't like the foreach, and that's because $file is returning a bool (false) isntead of an array. It was working earlier so I don't know what's up. I've already tried making it pasv. Here's the script running: http://www.clanxmc.com/pb/getSS.php <?php error_reporting(6143); /** * @author Xodus * @copyright 2007 * FTP TRANSFER! */ $ftp_server = "69.65.32.219"; $ftp_user_name = "2574"; $ftp_user_pass = "******"; $remoteSSPath = "/"; $destination_file = "./Unsorted/"; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; } $file = ftp_nlist($conn_id, $remoteSSPath); echo "<br>"; var_dump($file); foreach ($file as $files) { $ispng = false; $findMe = "png"; $ispng = strpos($files, $findMe); $newName = rand(1, 1000000); $newName .= ".png"; if ($ispng) { ftp_rename($conn_id, $files, $newName); $get = ftp_get($conn_id, $destination_file . $newName, $newName, FTP_BINARY); if (!$get) { echo "FTP download has failed downloading: $newName!<br>"; } else { echo "Downloaded $files to $destination_file <br>"; echo "Deleting $files:<br>"; if (ftp_delete($conn_id, $newName)) { echo "$newName Deleted! <br>"; } else echo "Error deleting file!"; } } else { echo "$files is not a .png file! - Not downloading <br>"; echo "Deleting $files:<br>"; if (ftp_delete($conn_id, $files)) { echo "$files Deleted! <br>"; } else echo "Error deleting file!"; } } ftp_close($conn_id); echo "<br>Closed FTP Session<br>"; ?> Any help would be appreciated. Thanks, Xodus Link to comment https://forums.phpfreaks.com/topic/63295-problem-with-ftp_nlist-suddenly/ Share on other sites More sharing options...
Xodus989 Posted August 4, 2007 Author Share Posted August 4, 2007 No edit? :/ Well, I tried a different ftp server, and it works, so it looks like I'm going to the gsp for answers. Link to comment https://forums.phpfreaks.com/topic/63295-problem-with-ftp_nlist-suddenly/#findComment-315446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.