I'm trying to create an FTP script that will copy a local folder structure upto an FTP point. Basically to update a website.
I have been testing the following code (have changed the user/pass/domain) but the connection doesn't fail and appears to be working.
$server = 'ftp.domainname.co';
$ftp_user_name = 'user';
$ftp_user_pass = 'pass';
$dest = '.';
$source = '.';
$mode = 'FTP_ASCII';
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) { die('Connection attempt failed!'); }
$upload = ftp_put($connection, $dest, $source, $mode);
if (!$upload) { echo 'FTP upload failed!'; }
ftp_close($connection);
I'm confident the point that is breaking is the ftp_put line. My questions are:
Can ftp_put upload an entire directory structure with files etc or is this just to upload one file at a time? Is there a different command I should be using?
I think I have something wrong with these variables:
$dest = '.'; $source = '.'; $mode = 'FTP_ASCII';
I believe mode is correct.
$dest - this is just the root of the ftp server being ftp.domainname.co - should I put the ftp server name or what goes here.
$source - this is a the current local path - I've also tried the full C:\etc path.
I get this error: Warning: ftp_put() expects parameter 4 to be long
any help would be great.
thx