Hi,
I am trying to upload some files using ftp via php.
I have built a function which should work as far as i can see but it isn't. Can anyone see why this would not work?
[PHP]
function ftpupload($file , $destination){
// set up the settings
$ftp_server = "ftp.".$_SESSIO N['domain'];
$ftpuser = $_SESSION['user'];
$ftppass = $_SESSION['pass'];
// delete the below variables if you decide to use a form.
$source_file = $file;
$destination_fi le = $destination;
// set up basic connection
$conn_id = ftp_connect($ft p_server);
// login with username and password
$login_result = ftp_login($conn _id, $ftpuser, $ftppass);
ftp_put($conn_i d, "$destination_f ile", "$source_fi le", FTP_BINARY); // the ftp function
// close the connection
ftp_close($conn _id);
}
[/PHP]
Then:
[PHP]
ftpupload($rand _name.$file_ext , "/uploads/images/thumbs/");
[/PHP]
Any Ideas?
Cheers,
Adam
I am trying to upload some files using ftp via php.
I have built a function which should work as far as i can see but it isn't. Can anyone see why this would not work?
[PHP]
function ftpupload($file , $destination){
// set up the settings
$ftp_server = "ftp.".$_SESSIO N['domain'];
$ftpuser = $_SESSION['user'];
$ftppass = $_SESSION['pass'];
// delete the below variables if you decide to use a form.
$source_file = $file;
$destination_fi le = $destination;
// set up basic connection
$conn_id = ftp_connect($ft p_server);
// login with username and password
$login_result = ftp_login($conn _id, $ftpuser, $ftppass);
ftp_put($conn_i d, "$destination_f ile", "$source_fi le", FTP_BINARY); // the ftp function
// close the connection
ftp_close($conn _id);
}
[/PHP]
Then:
[PHP]
ftpupload($rand _name.$file_ext , "/uploads/images/thumbs/");
[/PHP]
Any Ideas?
Cheers,
Adam
Comment