<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Opens an Secure SSL-FTP connection</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ftp-size.html">ftp_size</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ftp-systype.html">ftp_systype</a></div> <div class="up"><a href="ref.ftp.html">FTP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.ftp-ssl-connect" class="refentry"> <div class="refnamediv"> <h1 class="refname">ftp_ssl_connect</h1> <p class="verinfo">(PHP 4 >= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">ftp_ssl_connect</span> — <span class="dc-title">Opens an Secure SSL-FTP connection</span></p> </div> <div class="refsect1 description" id="refsect1-function.ftp-ssl-connect-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><strong>ftp_ssl_connect</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = 21</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$timeout</code><span class="initializer"> = 90</span></span> ]] )</div> <p class="para rdfs-comment"> <span class="function"><strong>ftp_ssl_connect()</strong></span> opens an explicit SSL-FTP connection to the specified <em><code class="parameter">host</code></em>. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <strong>Why this function may not exist</strong><br /> <p class="para"> <span class="function"><strong>ftp_ssl_connect()</strong></span> is only available if both the ftp module and the <a href="ref.openssl.html" class="link">OpenSSL</a> support is built statically into php, this means that on Windows this function will be undefined in the official PHP builds. To make this function available on Windows you must compile your own PHP binaries. </p> </p></blockquote> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> <span class="function"><strong>ftp_ssl_connect()</strong></span> is not intended for use with sFTP. To use sFTP with PHP, please see <span class="function"><a href="function.ssh2-sftp.html" class="function">ssh2_sftp()</a></span>. </p> </p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-function.ftp-ssl-connect-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">host</code></em></span> <dd> <p class="para"> The FTP server address. This parameter shouldn't have any trailing slashes and shouldn't be prefixed with <em>ftp://</em>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">port</code></em></span> <dd> <p class="para"> This parameter specifies an alternate port to connect to. If it is omitted or set to zero, then the default FTP port, 21, will be used. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">timeout</code></em></span> <dd> <p class="para"> This parameter specifies the timeout for all subsequent network operations. If omitted, the default value is 90 seconds. The timeout can be changed and queried at any time with <span class="function"><a href="function.ftp-set-option.html" class="function">ftp_set_option()</a></span> and <span class="function"><a href="function.ftp-get-option.html" class="function">ftp_get_option()</a></span>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.ftp-ssl-connect-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a SSL-FTP stream on success or <strong><code>FALSE</code></strong> on error. </p> </div> <div class="refsect1 changelog" id="refsect1-function.ftp-ssl-connect-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.2.2</td> <td> The function was changed to return <strong><code>FALSE</code></strong> when it can't use an SSL connection, instead of fallbacking to a non-SSL one as previously. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.ftp-ssl-connect-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4308"> <p><strong>Example #1 <span class="function"><strong>ftp_ssl_connect()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// set up basic ssl connection<br /></span><span style="color: #0000BB">$conn_id </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_ssl_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp_server</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// login with username and password<br /></span><span style="color: #0000BB">$login_result </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_login</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">, </span><span style="color: #0000BB">$ftp_user_name</span><span style="color: #007700">, </span><span style="color: #0000BB">$ftp_user_pass</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">ftp_pwd</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">); </span><span style="color: #FF8000">// /<br /><br />// close the ssl connection<br /></span><span style="color: #0000BB">ftp_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.ftp-ssl-connect-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.ftp-connect.html" class="function" rel="rdfs-seeAlso">ftp_connect()</a> - Opens an FTP connection</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ftp-size.html">ftp_size</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ftp-systype.html">ftp_systype</a></div> <div class="up"><a href="ref.ftp.html">FTP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>