Tuesday, April 6, 2010

php ftp class

usage of the class - get a file

require("class.ftp.php"); //include library

$f=new PHP_FTP('ftp.somesite.com', 'username', 'password'); //specify
connect info

$f->get('html/test.txt', 'c:/php/ftp/blah.txt'); //yes, tested on Windows

$f->kill(); //optional destroy class method

?>


Usage Example - Send a file

require("class.ftp.php");

$f=new PHP_FTP('ftp.somesite.com', 'username', 'password', 21); //optional port as 4th arg

$f->send('c:/php/ftp/blah.txt', 'html/test.txt'); //yes, tested on Windows

$f->kill();

?>

Usage Example - how to test for completion

if(!$f->send('c:/php/ftp/blah.txt', 'html/test.txt')){

echo
"File sent
successfully!"
;

}else{

echo
"Error
sending file."
;

}

?>

you can download it here


1 comment:

Danny said...

I have been looking around for this kind of information. Will you post some more in future.I've been doing some research on which top seo company would be the best for me. I'm really looking for a company that knows what they're doing and have me and my site's best interest in mind. I figure they'll do well if my work is doing well. One of the places I'm looking into is www.bergstrom-seo.com. I was wondering if you've ever dealt with them and what your opinion of them is. I'm kind of nervous about just jumping in and working with a company before I get other people's opinions on them. I really like to hear about others' experiences. Working with a top seo company is new to me so I'd rather use good judgement than just a gut feeling when deciding who to work with.