ftp_base::put()publicWP 1.0

Method of the class: ftp_base{}

No Hooks.

Return

null. Nothing (null).

Usage

$ftp_base = new ftp_base();
$ftp_base->put( $localfile, $remotefile, $rest );
$localfile (required)
-
$remotefile **
-
Default: NULL
$rest **
-

ftp_base::put() code WP 6.5.2

function put($localfile, $remotefile=NULL, $rest=0) {
	if(is_null($remotefile)) $remotefile=$localfile;
	if (!file_exists($localfile)) {
		$this->PushError("put","cannot open local file", "No such file or directory \"".$localfile."\"");
		return FALSE;
	}
	$fp = @fopen($localfile, "r");

	if (!$fp) {
		$this->PushError("put","cannot open local file", "Cannot read file \"".$localfile."\"");
		return FALSE;
	}
	if($this->_can_restore and $rest!=0) fseek($fp, $rest);
	$pi=pathinfo($localfile);
	if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
	else $mode=FTP_BINARY;
	if(!$this->_data_prepare($mode)) {
		fclose($fp);
		return FALSE;
	}
	if($this->_can_restore and $rest!=0) $this->restore($rest);
	if(!$this->_exec("STOR ".$remotefile, "put")) {
		$this->_data_close();
		fclose($fp);
		return FALSE;
	}
	if(!$this->_checkCode()) {
		$this->_data_close();
		fclose($fp);
		return FALSE;
	}
	$ret=$this->_data_write($mode, $fp);
	fclose($fp);
	$this->_data_close();
	if(!$this->_readmsg()) return FALSE;
	if(!$this->_checkCode()) return FALSE;
	return $ret;
}