<?php $FTP_HOST ="www.YOURDOMAIN.com"; $FTP_USER ="YOURUSERNAME"; $FTP_PW ="YOURPASSWORD"; $FTP_ROOT_DIR="/"; $LOCAL_SERVER_DIR = "avatars/"; $FTP_DIR = "REMOTE/DRICTORY"; $handle=opendir($LOCAL_SERVER_DIR); while (($file = readdir($handle))!==false) { if(!is_dir($file)){ $f[]="$file"; } } closedir($handle); sort($f); $count=0; $mode = FTP_BINARY; $conn_id = ftp_connect($FTP_HOST); if(ftp_login($conn_id, $FTP_USER, $FTP_PW)){ print "from: ".$LOCAL_SERVER_DIR."<br>"; print "to: ".$FTP_HOST.$FTP_ROOT_DIR.$FTP_DIR."<br>"; ftp_pwd($conn_id); ftp_chdir($conn_id,$FTP_DIR); foreach($f as $files) { $from = fopen($LOCAL_SERVER_DIR.$files,"r"); if(ftp_fput($conn_id, $files, $from, $mode)){ $count +=1; // print $files."<br>"; } } ftp_quit($conn_id); } print "upload : $count files."; ?>