I'm trying to upload a submitted CV from job applicants to a remote ftp server.
I've wrapped all the steps into "if...else echo" statements and they are all successful (fopen, ftp_connect, ftp_login), but it gets stuck at the fpt_fput statement with this error:
ftp_put() expects parameter 1 to be resource, boolean given in /var/www/*******/phpmailer/sendmail.php on line 286
I've checked whether it could be SELinux, but it's not running on that server.
Here is the code for that section in the php file:
$location = "uploads/" . $finalCV;
//move_uploaded_file($_FILES['applCV']['tmp_name'], $location);
//Move uploaded & renamed CV to server
if($fp = fopen($location, 'r'))
echo "File Open Successful. ";
else {
echo "File Open Unsuccessful. ";
}
if($conn_id = ftp_connect("some.server"))
echo "FTP Connection Established Successfully. ";
else {
echo "FTP Connection Failed. ";
}
$ftpuser = "wynand";
$ftppasswd = "********";
if($login = ftp_login($conn_id, $ftpuser, $ftppasswd)) {
echo "FTP Login Successful. ";
}
else {
echo "FTP Login Unsuccessful. ";
}
if(ftp_put($login, $location, $fp, FTP_ASCII)) {
echo "Successfully uploaded CV. ";
}
else {
echo "There was a problem uploading CV. ";
}
ftp_loginreturns a true/false for the login, which cannot be used for the identifier. You need to use the$conn_idresource identifier instead. - aynber