Re: Store file remotely using socket/fopen

From: Date: Fri, 26 Oct 2001 20:58:03 +0000
Subject: Re: Store file remotely using socket/fopen
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72502@lists.php.net to get a copy of this message
The command is STOR not STORE. Take a look at the FTP RFC- I think its 951, but im not 100%- just search for FTP RFC. On Friday 26 October 2001 05:42 am, you wrote: > Hello list, > > Simple Enough Objective: store file remotely (wu-ftp); > MinorSnag: PHP's ftp-functions unavailable at localhost; > BelowWorkaround: works fine for deleting remote file; > MajorSnag: how to STORE a file remotely using socket? > > <?php > $ftp=fsockopen("ftp.server.com", 21, $errno, $errstr, 60); > if (!$ftp) { > echo "Connection failed: $errstr ($errno)"; > exit; > } > else { > socket_set_blocking($ftp, true); > echo fgets($ftp,255); > fputs($ftp,"USER ftp_username\r\n"); > echo fgets($ftp,255); > fputs($ftp,"PASS ftp_passw\r\n"); > echo fgets($ftp,255); > fputs($ftp,"DELE /home/httpd/html/test.htm\r\n"); > echo fgets($ftp,255); > fputs($ftp,"QUIT\r\n"); > echo fgets($ftp,255); > fclose($ftp); > } > ?> > > BTW: I also messed with fopen("ftp://user:pass@...") > but failed miserably (although it seemed possible before > my mind wandered off). > > ANY HELP IS APPRECIATED (using socket, fopen, ...) > -- > SpeedFreak@chello.be

« previous php.general (#72502) next »