By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,515 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,515 IT Pros & Developers. It's quick & easy.

class for FTP

P: n/a
Hi!

I wrote class for sending files via FTP. I hvae problem when I try to
use it. I see this message:

Warning: ftp_put() expects parameter 1 to be resource, boolean given in
D:\klasy\class.ftp.inc on line 32

Why it not works? Have you got any suggestions?

Piotr Szumny

file: class.ftp.inc
-------------------
<?
class FTP {
var $conn_id;
var $result;
var $ftp_host;
var $ftp_user;
var $ftp_pass;
var $ftp_method;

function FTP($host,$user,$pass) {
$this->ftp_host = $host;
$this->ftp_user = $user;
$this->ftp_pass = $pass;
//connection with ftp server
$this->conn_id = ftp_connect( $ftp_host );
if (!$this->conn_id) return false;
$this->result = ftp_login( $this->conn_id, $this->ftp_user,
$this->ftp_pass );
if (!$this->result) return false;
//settings
$this->result = ftp_set_option($this->conn_id,FTP_TIMEOUT_SEC,120);
if (!$this->result) return false;
$this->result = ftp_pasv( $this->conn_id, true );
if (!$this->result) return false;
return true;
}

function changePassive($tf) {
return ftp_pasv( $this->conn_id, $tf );
}

function putFile($fn_dest, $fn_source, $method = FTP_BINARY) {
return ftp_put ( $this->conn_id, $fn_dest, $fn_source, $method );
}

function close() {
ftp_close( $this->conn_id );
}

} //end class
?>
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Give us the code how you use it, so we can see the problem more deeply ...

Savut

"Piotr Szumny" <sz****@klub.chip.pl> wrote in message
news:3f******@news.vogel.pl...
Hi!

I wrote class for sending files via FTP. I hvae problem when I try to
use it. I see this message:

Warning: ftp_put() expects parameter 1 to be resource, boolean given in
D:\klasy\class.ftp.inc on line 32

Why it not works? Have you got any suggestions?

Piotr Szumny

file: class.ftp.inc
-------------------
<?
class FTP {
var $conn_id;
var $result;
var $ftp_host;
var $ftp_user;
var $ftp_pass;
var $ftp_method;

function FTP($host,$user,$pass) {
$this->ftp_host = $host;
$this->ftp_user = $user;
$this->ftp_pass = $pass;
//connection with ftp server
$this->conn_id = ftp_connect( $ftp_host );
if (!$this->conn_id) return false;
$this->result = ftp_login( $this->conn_id, $this->ftp_user,
$this->ftp_pass );
if (!$this->result) return false;
//settings
$this->result = ftp_set_option($this->conn_id,FTP_TIMEOUT_SEC,120);
if (!$this->result) return false;
$this->result = ftp_pasv( $this->conn_id, true );
if (!$this->result) return false;
return true;
}

function changePassive($tf) {
return ftp_pasv( $this->conn_id, $tf );
}

function putFile($fn_dest, $fn_source, $method = FTP_BINARY) {
return ftp_put ( $this->conn_id, $fn_dest, $fn_source, $method );
}

function close() {
ftp_close( $this->conn_id );
}

} //end class
?>

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.