Is it possible to upload a file into a subfolder on an FTP server?
I send a file daily to an FTP server, scheduled on a cron job that runs a php file. It all works fine, but now I’ve been asked to change the destination to a subfolder.
Changing *$server_name = ‘ftp.website.com’* to *$server_name = ‘ftp.website.com/data’*
doesn’t seem to work?
I can see the folder exists in filezilla and it has all read/write access in permissions.
I’d be grateful if someone can advise if its a permission issue or whether it’s possible at all?
Thanks in advance.
CODE…
//FTP bit...
$server_name = 'ftp.website.com';
$server_username = 'xxxx';
$server_password = 'xxxx';
$conn_id = ftp_connect($server_name);
$login_result = ftp_login($conn_id, $server_username, $server_password);
ftp_pasv($conn_id, true);
ftp_put($conn_id, $zip_filename, $output_dir . $zip_filename, FTP_BINARY);
Seems like you need to use
ftp_chdir().Connect as normal, and then change directories using
ftp_chdir().