I am uploading file on ftp using PHP. I have created a class to create directory/ upload file etc. I am passing ftp login details like this
$ftp_server="";
$ftp_user="";
$ftp_pass="";
//variable that connects to the FTP server
$connect = ftp_connect('',21,120);
//logins into FTP server account
ftp_login($connect, $ftp_user, $ftp_pass);
$uploader = new Uploader();
$pusher->Uploader("abc.php","abc_feeds.php",$connect);
This is working fine but i want to add ftp_connect function inside my Uploader class and then pass $this->ftpConnect into the method like this
private function connect(){
if (!isset($this->ftp)){
$ftpConn= ftp_connect('',21,120) or die ("Cannot connect to host");
$this->ftpConnect = $ftpConn;
$ftpLogin=ftp_login($ftpConn, $this->ftp["user"], $this->ftp["pass"]) or die("Cannot login, wrong username or password");
ftp_pasv($this->ftp, true);
$this->status = 'Connected';
}
}
public function upload($filePath, $desPath) {
....
if (ftp_mkdir($this->ftpConnect, $this->ftpDrop)) {
echo "successfully created $dir\n";
} else {
echo "Error";
....
}
But the problem is $this->ftpConnect is passing null. Any suggestions? }