I'm trying to transfer files from a webserver to a mms server, using ftp.
I get a access denied error message, even when logged on to the server. I'm unable to set UID:
// open some file for reading
$file = $_FILES['uploadfile']['tmp_name'];
$fp = fopen($file, 'r');
// login with username and password
$conn_id = ftp_connect('mms.servername.no');
$login_result = ftp_login($conn_id, 'user', 'pass');
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected to server";
}
// try to upload $file
$origUID = posix_getuid();
if(posix_setuid(0)) { // not working
if (ftp_fput($conn_id, "/foldername".$file, $fp, FTP_BINARY)) {
echo "Successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
posix_setuid($origUID);
}
else {
echo "error setting UID";
}
// close the connection and the file handler
ftp_close($conn_id);
fclose($fp);
Can anyone help?