Change gravityform upload folder to a new host via ftp
Change gravityform upload folder to a new host via ftp
we have a gravityform which has a multiple upload field and want when user upload files the files upload to a second host via ftp connection how can we implement this?
here what we do until now the main site is mysite.com and the subdomain which hosted on another hsoting is files.mysite.com
add_filter( 'gform_upload_path', 'change_upload_path', 10, 2 );
function change_upload_path( $path_info, $form_id ) {
// FTP credentials for host two
$ftp_host = '***';
$ftp_username = '***';
$ftp_password = '***';
// Remote path on host two where files should be uploaded
$remote_path = '/public_html/guaranty_uploads/';
// Connect to host two via FTP
$ftp_connection = ftp_connect($ftp_host);
ftp_login($ftp_connection, $ftp_username, $ftp_password);
// Set the FTP upload directory on host two
ftp_chdir($ftp_connection, $remote_path);
// Update the path_info array with the FTP details
$path_info['path'] = $remote_path;
$path_info['url'] = 'http://files.mysite.com/guaranty_uploads/';
$path_info['ftp_connection'] = $ftp_connection;
return $path_info;
}
best regards
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand