<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >ftp_nb_get</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual PHP" HREF="index.html"><LINK REL="UP" TITLE="FTP Functions" HREF="ref.ftp.html"><LINK REL="PREVIOUS" TITLE="ftp_nb_fput" HREF="function.ftp-nb-fput.html"><LINK REL="NEXT" TITLE="ftp_nb_put" HREF="function.ftp-nb-put.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-2"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.ftp-nb-fput.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ftp-nb-put.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.ftp-nb-get" ></A >ftp_nb_get</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN31749" ></A ><P > (PHP 4 >= 4.3.0, PHP 5)</P >ftp_nb_get -- Retrieves a file from the FTP server and writes it to a local file (non-blocking)</DIV ><DIV CLASS="refsect1" ><A NAME="AEN31752" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >ftp_nb_get</B > ( resource ftp_stream, string local_file, string remote_file, int mode [, int resumepos])<BR ></BR ><P > <B CLASS="function" >ftp_nb_get()</B > retrieves <VAR CLASS="parameter" >remote_file</VAR > from the FTP server, and saves it to <VAR CLASS="parameter" >local_file</VAR > locally. The transfer <VAR CLASS="parameter" >mode</VAR > specified must be either <TT CLASS="constant" ><B >FTP_ASCII</B ></TT > or <TT CLASS="constant" ><B >FTP_BINARY</B ></TT >. The difference between this function and the <A HREF="function.ftp-get.html" ><B CLASS="function" >ftp_get()</B ></A > is that this function retrieves the file asynchronously, so your program can perform other operations while the file is being downloaded. </P ><P > Returns <TT CLASS="constant" ><B >FTP_FAILED</B ></TT >, <TT CLASS="constant" ><B >FTP_FINISHED</B ></TT >, or <TT CLASS="constant" ><B >FTP_MOREDATA</B ></TT >. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN31785" ></A ><P ><B >Exemplu 1. <B CLASS="function" >ftp_nb_get()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br /></font><font color="#FF8000">// Initate the download<br /></font><font color="#0000BB">$ret </font><font color="#007700">= </font><font color="#0000BB">ftp_nb_get</font><font color="#007700">(</font><font color="#0000BB">$my_connection</font><font color="#007700">, </font><font color="#DD0000">"test"</font><font color="#007700">, </font><font color="#DD0000">"README"</font><font color="#007700">, </font><font color="#0000BB">FTP_BINARY</font><font color="#007700">);<br />while (</font><font color="#0000BB">$ret </font><font color="#007700">== </font><font color="#0000BB">FTP_MOREDATA</font><font color="#007700">) {<br /> <br /> </font><font color="#FF8000">// Do whatever you want<br /> </font><font color="#007700">echo </font><font color="#DD0000">"."</font><font color="#007700">;<br /><br /> </font><font color="#FF8000">// Continue downloading...<br /> </font><font color="#0000BB">$ret </font><font color="#007700">= </font><font color="#0000BB">ftp_nb_continue</font><font color="#007700">(</font><font color="#0000BB">$my_connection</font><font color="#007700">);<br />}<br />if (</font><font color="#0000BB">$ret </font><font color="#007700">!= </font><font color="#0000BB">FTP_FINISHED</font><font color="#007700">) {<br /> echo </font><font color="#DD0000">"There was an error downloading the file..."</font><font color="#007700">;<br /> exit(</font><font color="#0000BB">1</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN31789" ></A ><P ><B >Exemplu 2. Resuming a download with <B CLASS="function" >ftp_nb_get()</B ></B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br /></font><font color="#FF8000">// Initate <br /></font><font color="#0000BB">$ret </font><font color="#007700">= </font><font color="#0000BB">ftp_nb_get</font><font color="#007700">(</font><font color="#0000BB">$my_connection</font><font color="#007700">, </font><font color="#DD0000">"test"</font><font color="#007700">, </font><font color="#DD0000">"README"</font><font color="#007700">, </font><font color="#0000BB">FTP_BINARY</font><font color="#007700">, <br /> </font><font color="#0000BB">filesize</font><font color="#007700">(</font><font color="#DD0000">"test"</font><font color="#007700">));<br /></font><font color="#FF8000">// OR: $ret = ftp_nb_get($my_connection, "test", "README", <br />// FTP_BINARY, FTP_AUTORESUME);<br /></font><font color="#007700">while (</font><font color="#0000BB">$ret </font><font color="#007700">== </font><font color="#0000BB">FTP_MOREDATA</font><font color="#007700">) {<br /> <br /> </font><font color="#FF8000">// Do whatever you want<br /> </font><font color="#007700">echo </font><font color="#DD0000">"."</font><font color="#007700">;<br /><br /> </font><font color="#FF8000">// Continue downloading...<br /> </font><font color="#0000BB">$ret </font><font color="#007700">= </font><font color="#0000BB">ftp_nb_continue</font><font color="#007700">(</font><font color="#0000BB">$my_connection</font><font color="#007700">);<br />}<br />if (</font><font color="#0000BB">$ret </font><font color="#007700">!= </font><font color="#0000BB">FTP_FINISHED</font><font color="#007700">) {<br /> echo </font><font color="#DD0000">"There was an error downloading the file..."</font><font color="#007700">;<br /> exit(</font><font color="#0000BB">1</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN31793" ></A ><P ><B >Exemplu 3. Resuming a download at position 100 to a new file with <B CLASS="function" >ftp_nb_get()</B > </B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br /></font><font color="#FF8000">// Disable Autoseek<br /></font><font color="#0000BB">ftp_set_option</font><font color="#007700">(</font><font color="#0000BB">$my_connection</font><font color="#007700">, </font><font color="#0000BB">FTP_AUTOSEEK</font><font color="#007700">, </font><font color="#0000BB">false</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Initiate<br /></font><font color="#0000BB">$ret </font><font color="#007700">= </font><font color="#0000BB">ftp_nb_get</font><font color="#007700">(</font><font color="#0000BB">$my_connection</font><font color="#007700">, </font><font color="#DD0000">"newfile"</font><font color="#007700">, </font><font color="#DD0000">"README"</font><font color="#007700">, </font><font color="#0000BB">FTP_BINARY</font><font color="#007700">, </font><font color="#0000BB">100</font><font color="#007700">);<br />while (</font><font color="#0000BB">$ret </font><font color="#007700">== </font><font color="#0000BB">FTP_MOREDATA</font><font color="#007700">) {<br /><br /> </font><font color="#FF8000">/* ... */<br /> <br /> // Continue downloading...<br /> </font><font color="#0000BB">$ret </font><font color="#007700">= </font><font color="#0000BB">ftp_nb_continue</font><font color="#007700">(</font><font color="#0000BB">$my_connection</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > In the example above, <TT CLASS="filename" >"newfile"</TT > is 100 bytes smaller than <TT CLASS="filename" >"README"</TT > on the FTP server because we started reading at offset 100. If we have not have disabled <TT CLASS="constant" ><B >FTP_AUTOSEEK</B ></TT >, the first 100 bytes of <TT CLASS="filename" >"newfile"</TT > will be <VAR CLASS="literal" >'\0'</VAR >. </P ><P > See also <A HREF="function.ftp-nb-fget.html" ><B CLASS="function" >ftp_nb_fget()</B ></A >, <A HREF="function.ftp-nb-continue.html" ><B CLASS="function" >ftp_nb_continue()</B ></A >, <A HREF="function.ftp-get.html" ><B CLASS="function" >ftp_get()</B ></A >, and <A HREF="function.ftp-fget.html" ><B CLASS="function" >ftp_fget()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.ftp-nb-fput.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Acasã</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ftp-nb-put.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >ftp_nb_fput</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.ftp.html" ACCESSKEY="U" >Sus</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ftp_nb_put</TD ></TR ></TABLE ></DIV ></BODY ></HTML >