<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>El Ricon de Miller</title>
	<atom:link href="http://milerweb.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://milerweb.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 24 Jul 2008 23:10:13 +0000</lastBuildDate>
	<language>es</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='milerweb.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>El Ricon de Miller</title>
		<link>http://milerweb.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://milerweb.wordpress.com/osd.xml" title="El Ricon de Miller" />
	<atom:link rel='hub' href='http://milerweb.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Enviar email multiple con PHP</title>
		<link>http://milerweb.wordpress.com/2008/07/24/enviar-email-multiple-con-php/</link>
		<comments>http://milerweb.wordpress.com/2008/07/24/enviar-email-multiple-con-php/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 23:10:13 +0000</pubDate>
		<dc:creator>milerweb</dc:creator>
				<category><![CDATA[Ejemplos Importantes]]></category>

		<guid isPermaLink="false">http://milerweb.wordpress.com/?p=6</guid>
		<description><![CDATA[En algunas ocasiones nos topamos con la necesidad de enviar email a una lista de correo, esto lo podemos hacer utilizando la librería PHPMailer el cual nos permite enviar emails con algunas opciones avanzadas para este tipo de labores. Extraer datos de los destinatarios Sea que tenemos una lista de clientes registrados en una base [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=milerweb.wordpress.com&amp;blog=4318733&amp;post=6&amp;subd=milerweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>En algunas ocasiones nos topamos con la necesidad de enviar email a una lista de correo, esto lo podemos hacer utilizando la librería <a href="http://blog.unijimpe.net/introduccion-a-phpmailer/">PHPMailer</a> el cual nos permite enviar emails con algunas opciones avanzadas para este tipo de labores.</p>
<p style="text-align:center;"><img src="http://blog.unijimpe.net/wp-content/uploads/2008/06/mail-list.jpg" alt="" width="128" height="128" /></p>
<p><strong>Extraer datos de los destinatarios </strong><br />
Sea que tenemos una lista de clientes registrados en una base de datos <em>tienda</em> en la tabla <em>clientes</em> y deseamos enviarle un comunicado a cada uno de ellos de forma personalizada. Lo primero que tenemos que hacer es realizar la consulta a la base de datos y extraer los datos de estos clientes.</p>
<div class="syntax_hilite"><span class="langName">PHP:</span></p>
<div id="php-1">
<div class="php">
<ol>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><a href="http://www.php.net/mysql_connect"><span style="color:#000066;">mysql_connect</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#ff0000;">&#8220;localhost&#8221;</span>, <span style="color:#ff0000;">&#8220;usuario&#8221;</span>, <span style="color:#ff0000;">&#8220;password&#8221;</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><a href="http://www.php.net/mysql_select_db"><span style="color:#000066;">mysql_select_db</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#ff0000;">&#8220;tienda&#8221;</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#ff0000;">&#8220;SELECT nombres, email FROM clientes&#8221;</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#616100;">while</span> <span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$row</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color:#000066;">mysql_fetch_array</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$result</span><span style="font-weight:bold;color:#006600;">)</span><span style="font-weight:bold;color:#006600;">)</span> <span style="font-weight:bold;color:#006600;">{</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-style:italic;color:#ff9933;">// echo $row["nombres"];</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-weight:bold;color:#006600;">}</span></div>
</li>
</ol>
</div>
</div>
</div>
<p><strong>Integrando con PHPMailer</strong><br />
El siguiente paso es hacer el envío de los correos, para ello primero incluimos la clase <em>class.phpmailer.php</em>, definimos los datos del remitente y creamos el mensaje personalizado en html y texto a  enviar a la lista.</p>
<div class="syntax_hilite"><span class="langName">PHP:</span></p>
<div id="php-2">
<div class="php">
<ol>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#616100;">require</span><span style="font-weight:bold;color:#006600;">(</span><span style="color:#ff0000;">&#8220;class.phpmailer.php&#8221;</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li></li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span> = <span style="font-weight:bold;color:#000000;">new</span> PHPMailer<span style="font-weight:bold;color:#006600;">(</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">Host</span> = <span style="color:#ff0000;">&#8220;smtp1.example.com&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">From</span> = <span style="color:#ff0000;">&#8220;list@domain.com&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">FromName</span> = <span style="color:#ff0000;">&#8220;List manager&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">Subject</span> = <span style="color:#ff0000;">&#8220;Subject del correo&#8221;</span>;</div>
</li>
<li></li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><a href="http://www.php.net/mysql_connect"><span style="color:#000066;">mysql_connect</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#ff0000;">&#8220;localhost&#8221;</span>, <span style="color:#ff0000;">&#8220;usuario&#8221;</span>, <span style="color:#ff0000;">&#8220;password&#8221;</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><a href="http://www.php.net/mysql_select_db"><span style="color:#000066;">mysql_select_db</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#ff0000;">&#8220;tienda&#8221;</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#ff0000;">&#8220;SELECT nombres, email FROM clientes&#8221;</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#616100;">while</span> <span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$row</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color:#000066;">mysql_fetch_array</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$result</span><span style="font-weight:bold;color:#006600;">)</span><span style="font-weight:bold;color:#006600;">)</span> <span style="font-weight:bold;color:#006600;">{</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-style:italic;color:#ff9933;">// HTML body </span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$body</span> = <span style="color:#ff0000;">&#8220;Hola &lt;strong&gt;&#8221;</span>.<span style="color:#0000ff;">$row</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">"nombres"</span><span style="font-weight:bold;color:#006600;">]</span>.<span style="color:#ff0000;">&#8220;&lt;/strong&gt;, &#8220;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$body</span>.= <span style="color:#ff0000;">&#8220;&lt;p&gt;Les comunicamos el nuevo servicio&#8230; &lt;p&gt;&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$body</span>.= <span style="color:#ff0000;">&#8220;&lt;em&gt;List manager&lt;/em&gt;&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-style:italic;color:#ff9933;">// Text body</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$text</span> = <span style="color:#ff0000;">&#8220;Hola &#8220;</span>.<span style="color:#0000ff;">$row</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">"nombres"</span><span style="font-weight:bold;color:#006600;">]</span>.<span style="color:#ff0000;">&#8220;, <span style="font-weight:bold;color:#000099;">\n</span><span style="font-weight:bold;color:#000099;">\n</span>&#8220;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$text</span>.= <span style="color:#ff0000;">&#8220;Les comunicamos el nuevo servicio&#8230;<span style="font-weight:bold;color:#000099;">\n</span><span style="font-weight:bold;color:#000099;">\n</span>&#8220;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$text</span>.= <span style="color:#ff0000;">&#8220;List manager&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-style:italic;color:#ff9933;">// Configurar Email</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">Body</span> = <span style="color:#0000ff;">$body</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">AltBody</span> = <span style="color:#0000ff;">$text</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">AddAddress</span><span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$row</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">"email"</span><span style="font-weight:bold;color:#006600;">]</span>, <span style="color:#0000ff;">$row</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">"nombres"</span><span style="font-weight:bold;color:#006600;">]</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-style:italic;color:#ff9933;">// Enviar el email</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#616100;">if</span><span style="font-weight:bold;color:#006600;">(</span>!<span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">Send</span><span style="font-weight:bold;color:#006600;">(</span><span style="font-weight:bold;color:#006600;">)</span><span style="font-weight:bold;color:#006600;">)</span> <span style="font-weight:bold;color:#006600;">{</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#ff0000;">&#8220;Error al enviar a: &#8220;</span> . <span style="color:#0000ff;">$row</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">"email"</span><span style="font-weight:bold;color:#006600;">]</span> . <span style="color:#ff0000;">&#8220;&lt;br&gt;&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-weight:bold;color:#006600;">}</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$mail</span>-&gt;<span style="color:#006600;">ClearAddresses</span><span style="font-weight:bold;color:#006600;">(</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-weight:bold;color:#006600;">}</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>Nótese que incluimos la dirección del destinatario con el método <em>AddAddress</em> en donde le pasamos el email y el nombre de la persona a la que deseamos enviar el email y finalmente utilizamos <em>ClearAddresses</em> el cual elimina las email a los cuales se ha enviado anteriormente el mensaje, de esta forma le llegará a cada usuario una mensaje único si necesidad de mostrar a quienes mas se esta enviando el mensaje.</p>
<p><strong>Observaciones</strong><br />
En el caso que se quiera enviar a listas muy grandes, se deben cambiar algunos parámetros de configuración de PHP por ejemplo el tiempo de ejecución para que no se detenga el envío si el tiempo de proceso excede el tiempo de configuración. Una solución es hacer el envío en bloques de 500 o en bloques de 1000 por vez por ejemplo con lo cual no se superará el tiempo limite.</p>
<p>Finalmente les dejo los archivos fuente para que lo descarguen y realicen sus propias pruebas.</p>
<p style="text-align:center;"><a href="http://www.box.net/shared/pvjb4hv4s0"><img src="http://blog.unijimpe.net/btdown.png" border="0" alt="" /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/milerweb.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/milerweb.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/milerweb.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/milerweb.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/milerweb.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/milerweb.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/milerweb.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/milerweb.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/milerweb.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/milerweb.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/milerweb.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/milerweb.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/milerweb.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/milerweb.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/milerweb.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/milerweb.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=milerweb.wordpress.com&amp;blog=4318733&amp;post=6&amp;subd=milerweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://milerweb.wordpress.com/2008/07/24/enviar-email-multiple-con-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81c198614be1a5d1b82ccada20dd7b69?s=96&#38;d=identicon" medium="image">
			<media:title type="html">milerweb</media:title>
		</media:content>

		<media:content url="http://blog.unijimpe.net/wp-content/uploads/2008/06/mail-list.jpg" medium="image" />

		<media:content url="http://blog.unijimpe.net/btdown.png" medium="image" />
	</item>
		<item>
		<title>FTP Upload con PHP</title>
		<link>http://milerweb.wordpress.com/2008/07/24/ftp-upload-con-php/</link>
		<comments>http://milerweb.wordpress.com/2008/07/24/ftp-upload-con-php/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 22:49:00 +0000</pubDate>
		<dc:creator>milerweb</dc:creator>
				<category><![CDATA[Ejemplos Importantes]]></category>

		<guid isPermaLink="false">http://milerweb.wordpress.com/?p=3</guid>
		<description><![CDATA[Hoy les presentamos una guía de como implementar Upload de archivos por FTP utilizando PHP. Para ello nos hemos guiado de FTP Upload via cURL en donde esta muy bien explicado. Que necesitamos? cURL es una librería PHP muy potente la cual permite enviar y recibir archivos por diferentes protocolos (HTTP, FTP), además soporte envío [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=milerweb.wordpress.com&amp;blog=4318733&amp;post=3&amp;subd=milerweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hoy les presentamos una guía de como implementar Upload de archivos por FTP utilizando PHP. Para ello nos hemos guiado de <a href="http://www.web-development-blog.com/archives/tutorial-ftp-upload-via-curl/">FTP Upload via cURL</a> en donde esta muy bien explicado.</p>
<p><strong>Que necesitamos?</strong><br />
<em>cURL</em> es una librería PHP muy potente la cual permite enviar y recibir archivos por diferentes protocolos (<em>HTTP</em>, <strong>FTP</strong>), además soporte envío de datos por POST o GET, incluso permite autenticarse en servidores remotos. Entonces utilizaremos <strong>cURL</strong> para conectarnos al nuestro FTP y haremos la transferencia del archivo seleccionado.</p>
<p><strong>Creando el Formulario</strong><br />
Lo primero es crear un formulario en donde seleccionaremos el archivo a subir, esto de la siguiente forma:</p>
<div class="syntax_hilite"><span class="langName">HTML:</span></p>
<div id="html-1">
<div class="html">
<ol>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#009900;"><a href="http://december.com/html/4/element/form.html"><span style="font-weight:bold;color:#000000;">&lt;form</span></a> <span style="color:#000066;">action</span>=<span style="color:#ff0000;">&#8220;&#8221;</span> <span style="color:#000066;">method</span>=<span style="color:#ff0000;">&#8220;post&#8221;</span> <span style="color:#000066;">enctype</span>=<span style="color:#ff0000;">&#8220;multipart/form-data&#8221;</span><span style="font-weight:bold;color:#000000;">&gt;</span></span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;">Seleccionar archivo:</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#009900;"><a href="http://december.com/html/4/element/input.html"><span style="font-weight:bold;color:#000000;">&lt;input</span></a> <span style="color:#000066;">type</span>=<span style="color:#ff0000;">&#8220;file&#8221;</span> <span style="color:#000066;">name</span>=<span style="color:#ff0000;">&#8220;archivo&#8221;</span> /<span style="font-weight:bold;color:#000000;">&gt;</span></span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#009900;"><a href="http://december.com/html/4/element/input.html"><span style="font-weight:bold;color:#000000;">&lt;input</span></a> <span style="color:#000066;">type</span>=<span style="color:#ff0000;">&#8220;submit&#8221;</span> <span style="color:#000066;">name</span>=<span style="color:#ff0000;">&#8220;enviar&#8221;</span> <span style="color:#000066;">value</span>=<span style="color:#ff0000;">&#8220;Upload&#8221;</span> /<span style="font-weight:bold;color:#000000;">&gt;</span></span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#009900;"><a href="http://december.com/html/4/element/input.html"><span style="font-weight:bold;color:#000000;">&lt;input</span></a> <span style="color:#000066;">type</span>=<span style="color:#ff0000;">&#8220;hidden&#8221;</span> <span style="color:#000066;">name</span>=<span style="color:#ff0000;">&#8220;action&#8221;</span> <span style="color:#000066;">value</span>=<span style="color:#ff0000;">&#8220;upload&#8221;</span> /<span style="font-weight:bold;color:#000000;">&gt;</span></span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#009900;"><span style="font-weight:bold;color:#000000;">&lt;/form&gt;</span></span></div>
</li>
</ol>
</div>
</div>
</div>
<p><strong>Creando el Script</strong><br />
El siguiente paso es crear el php que se encargue de subir el archivo, primero verificamos que se haya seleccionado el archivo, luego creamos una variable <strong>cURL</strong> la cual asignamos con los valores que deseamos enviar y finalmente verificamos que se haya subido correctamente el archivo.</p>
<div class="syntax_hilite"><span class="langName">PHP:</span></p>
<div id="php-2">
<div class="php">
<ol>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$rpta</span> = <span style="color:#ff0000;">&#8220;&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#616100;">if</span> <span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$_POST</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">"action"</span><span style="font-weight:bold;color:#006600;">]</span> == <span style="color:#ff0000;">&#8220;upload&#8221;</span><span style="font-weight:bold;color:#006600;">)</span> <span style="font-weight:bold;color:#006600;">{</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$tmpfile</span> = <span style="color:#0000ff;">$_FILES</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">'archivo'</span><span style="font-weight:bold;color:#006600;">]</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">'tmp_name'</span><span style="font-weight:bold;color:#006600;">]</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$tmpname</span> = <span style="color:#0000ff;">$_FILES</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">'archivo'</span><span style="font-weight:bold;color:#006600;">]</span><span style="font-weight:bold;color:#006600;">[</span><span style="color:#ff0000;">'name'</span><span style="font-weight:bold;color:#006600;">]</span>;</div>
</li>
<li></li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$ftpuser</span> = <span style="color:#ff0000;">&#8220;usuario&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$ftppass</span> = <span style="color:#ff0000;">&#8220;password&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$ftppath</span> = <span style="color:#ff0000;">&#8220;ftp.dominio.com/path/&#8221;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$ftpurl</span> = <span style="color:#ff0000;">&#8220;ftp://&#8221;</span>.<span style="color:#0000ff;">$ftpuser</span>.<span style="color:#ff0000;">&#8220;:&#8221;</span>.<span style="color:#0000ff;">$ftppass</span>.<span style="color:#ff0000;">&#8220;@&#8221;</span>.<span style="color:#0000ff;">$ftppath</span>;</div>
</li>
<li></li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#616100;">if</span> <span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$tmpname</span> != <span style="color:#ff0000;">&#8220;&#8221;</span><span style="font-weight:bold;color:#006600;">)</span> <span style="font-weight:bold;color:#006600;">{</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$fp</span> = <a href="http://www.php.net/fopen"><span style="color:#000066;">fopen</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$tmpfile</span>, <span style="color:#ff0000;">&#8216;r&#8217;</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$ch</span> = curl_init<span style="font-weight:bold;color:#006600;">(</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;">curl_setopt<span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$ch</span>, CURLOPT_URL, <span style="color:#0000ff;">$ftpurl</span>.<span style="color:#0000ff;">$tmpname</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;">curl_setopt<span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$ch</span>, CURLOPT_UPLOAD, <span style="color:#800000;">1</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;">curl_setopt<span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$ch</span>, CURLOPT_INFILE, <span style="color:#0000ff;">$fp</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;">curl_setopt<span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$ch</span>, CURLOPT_INFILESIZE, <a href="http://www.php.net/filesize"><span style="color:#000066;">filesize</span></a><span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$tmpfile</span><span style="font-weight:bold;color:#006600;">)</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;">curl_exec<span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$ch</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$error</span> = curl_errno<span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$ch</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;">curl_close <span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$ch</span><span style="font-weight:bold;color:#006600;">)</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#616100;">if</span> <span style="font-weight:bold;color:#006600;">(</span><span style="color:#0000ff;">$error</span> == <span style="color:#800000;">0</span><span style="font-weight:bold;color:#006600;">)</span> <span style="font-weight:bold;color:#006600;">{</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$rpta</span> = <span style="color:#ff0000;">&#8216;Archivo subido correctamente.&#8217;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-weight:bold;color:#006600;">}</span> <span style="color:#616100;">else</span> <span style="font-weight:bold;color:#006600;">{</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$rpta</span> = <span style="color:#ff0000;">&#8216;Error al subir el archivo.&#8217;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-weight:bold;color:#006600;">}</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-weight:bold;color:#006600;">}</span> <span style="color:#616100;">else</span> <span style="font-weight:bold;color:#006600;">{</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="color:#0000ff;">$rpta</span> = <span style="color:#ff0000;">&#8216;Seleccionar un archivo.&#8217;</span>;</div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-weight:bold;color:#006600;">}</span></div>
</li>
<li>
<div style="font-family:'Courier New',Courier,monospace;font-weight:normal;font-size:12px;"><span style="font-weight:bold;color:#006600;">}</span></div>
</li>
</ol>
</div>
</div>
</div>
<p>Como puede ver no es muy complicado este tipo de implementación y tiene la ventaja que podemos enviar archivos mas grandes que con upload de forma normal. No he puesto una versión de este ejemplo funcionando pues quiero evitar que suban archivos no deseados. Finalmente les dejo los archivos fuente de este ejemplo en donde solo deben colocar el usuario, clave y dominio a donde desean subir.</p>
<p style="text-align:center;"><a href="http://www.box.net/shared/1nf061mo35"><img src="http://blog.unijimpe.net/btdown.png" border="0" alt="" /></a></p>
<p><!-- Related Posts --><strong><br />
</strong></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/milerweb.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/milerweb.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/milerweb.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/milerweb.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/milerweb.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/milerweb.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/milerweb.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/milerweb.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/milerweb.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/milerweb.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/milerweb.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/milerweb.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/milerweb.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/milerweb.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/milerweb.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/milerweb.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=milerweb.wordpress.com&amp;blog=4318733&amp;post=3&amp;subd=milerweb&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://milerweb.wordpress.com/2008/07/24/ftp-upload-con-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/81c198614be1a5d1b82ccada20dd7b69?s=96&#38;d=identicon" medium="image">
			<media:title type="html">milerweb</media:title>
		</media:content>

		<media:content url="http://blog.unijimpe.net/btdown.png" medium="image" />
	</item>
	</channel>
</rss>
