First,I want to ask😃oes php ftp function support resume files.if no.that is my code use socket.
<?php
$fp = fsockopen("wg", 21, &$errno, &$errstr, 10);
if(!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
$aa= fgets($fp,256);
echo "$aa<br>";
fputs($fp,"USER wg1\r\n");
echo fgets($fp,256);
echo "<br>";
$ret=fputs($fp,"PASS \r\n");
echo fgets($fp,256);
echo "<br>";
$ret=fputs($fp,"TYPE I\r\n");
echo fgets($fp,256);
echo "<br>";
$ret=fputs($fp,"REST 100\r\n");
echo fgets($fp,256);
echo "<br>";
$ret=fputs($fp,"REST 0\r\n");
echo fgets($fp,256);
echo "<br>";
$ret=fputs($fp,"pwd\r\n");
echo fgets($fp,256);
echo "<br>";
$ret=fputs($fp,"TYPE A\r\n");
echo fgets($fp,256);
echo "<br>";
$ret=fputs($fp,"retr wgnote.txt\r\n");
echo fgets($fp,256);
echo "<br>";
echo fgets($fp,256);
echo "<br>";
echo fgets($fp,256);
echo "<br>";
$ret=fclose($fp);
}
?>
the result is:
220 wg Microsoft FTP Service (Version 5.0).
331 Password required for wg1.
230-Hello,This is Wg's FTP Server
230 User wg1 logged in.
200 Type set to I.
350 Restarting at 100.
350 Restarting at 0.
257 "/" is current directory.
200 Type set to A.
150 Opening ASCII mode data connection for wgnote.txt(18538 bytes).
But I can't get wgnote.txt file stream.How can I read it and write it into a local file.