note 11222 added to fsockopen
| From: | RedBehelit at Yahoo dot com | Date: | Sun, 11 Feb 2001 04:10:27 +0000 |
| Subject: | note 11222 added to fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-10895@lists.php.net to get a copy of this message | ||
If you're trying to connect to an FTP address without using ftp_connect(); then you can do
this:
$tftp = fsockopen("ftp.blah.com", 21, $errno, $errstr, 60) or die("Connection
failed.");
socket_set_blocking($tftp, false);
fputs($tftp, "USER username\n");
fputs($tftp, "PASS password\n");
fputs($tftp, "DELE /home/somefilename.blh\n");
sleep(1);
fclose($tftp);
NOTE THE "sleep(1);" THIS IS REQUIRED. I had a few problems where it was not executing the
commands if I had not added the a delay after the actual fput requests. I guess what was happening
was that it was closing the FTP connection before it could actually finish the commands on the
servers side.
http://www.php.net/manual/en/function.fsockopen.php