This is a function i wrote to copy a complete directory to a FTP-Server-folder.
function ftp_uploaddirectory($conn_id, $local_dir, $remote_dir)
{
@ftp_mkdir($conn_id, $remote_dir);
$handle = opendir($local_dir);
while (($file = readdir($handle)) !== false)
{
if (($file != '.') && ($file != '..'))
{
if (is_dir($local_dir.$file))
{
ftp_uploaddirectory($conn_id, $local_dir.$file.'/', $remote_dir.$file.'/');
}
else
$f[] = $file;
}
}
closedir($handle);
if (count($f))
{
sort($f);
@ftp_chdir($conn_id, $remote_dir);
foreach ($f as $files)
{
$from = @fopen("$local_dir$files", 'r');
@ftp_fput($conn_id, $files, $from, FTP_BINARY);
}
}
}
Example:
$conn_id = @ftp_connect($server);
@ftp_login ($conn_id, $username, $passwort);
ftp_uploaddirectory($conn_id, 'mydirectory/', 'theftpdirectory/');
@ftp_quit($conn_id);
I hope you'll find it useful.