1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-24 07:22:16 +01:00
Files
archived-doc-es/reference/ftp/examples.xml
2025-06-29 19:03:52 +02:00

68 lines
1.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 4d1c34c9b7a30cfc3a59641122c707a2812cfed7 Maintainer: PhilDaiguille Status: ready -->
<!-- Reviewed: no -->
<chapter xml:id="ftp.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="ftp.examples-basic">
<title>Uso básico</title>
<para>
<example>
<title>Ejemplo con FTP</title>
<programlisting role="php">
<![CDATA[
<?php
// Establecimiento de una conexión básica
$ftp = ftp_connect($ftp_server);
// Identificación con un nombre de usuario y una contraseña
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
// Verificación de la conexión
if ((!$ftp) || (!$login_result)) {
echo "¡La conexión FTP ha fallado!";
echo "Intento de conexión al servidor $ftp_server para el usuario $ftp_user_name";
exit;
} else {
echo "Conexión al servidor $ftp_server, para el usuario $ftp_user_name";
}
// Carga de un fichero
$upload = ftp_put($ftp, $destination_file, $source_file, FTP_BINARY);
// Verificación del estado de la carga
if (!$upload) {
echo "¡La carga FTP ha fallado!";
} else {
echo "Carga de $source_file hacia $ftp_server como $destination_file";
}
// Cierre de la conexión FTP
ftp_close($ftp);
?>
]]>
</programlisting>
</example>
</para>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=xml
vi: ts=1 sw=1
-->