Ok, After much trial and error and finding a script that was similar but did it all in reverse I have made one that does exactly what I want. This is how to upload a whole, or in my case two whole dirs to an FTP. There is another part that does directories, but since I won't have any dirs I got rid of it.
Code:
<?
$ftp_server = "";
$ftp_user_name = "";
$ftp_user_pass = "";
$ftp_dir = "/images1/";
$ftp_dir2 = "/thumbs1/";
$dirLocal = "C:\\xampp\\htdocs\\images\\";
$dirLocal2 = "C:\\xampp\\htdocs\\thumbs\\";
// 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);
echo "Starting ".time()."<br>";
transferFiles($ftp_dir, $dirLocal);
transferFiles($ftp_dir2, $dirLocal2);
function transferFiles($dirRemote, $dirLocal){
global $conn_id;
if ($conn_id != false){
// get contents of the current directory
$contents = scandir($dirLocal);
foreach($contents as $file){
if (filesize($dirLocal.$file) > 0) {
echo "<i>$dirLocal$file</i><br>";
//If File Exists Skip.
if (ftp_size($conn_id,$dirRemote.$file) == filesize($dirLocal.$file)){
echo "- skipped <br>";
}
else {
ftp_put($conn_id, $dirRemote.$file, $dirLocal.$file, FTP_BINARY);
unlink($dirLocal.$file);
echo "- completed <br>";
}
}
}
}
}
?>
I hope this serves someones use sometime in the future.
Bookmarks