<?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/"
	>

<channel>
	<title>Incero &#187; ftp</title>
	<atom:link href="http://www.incero.com/tag/ftp/feed" rel="self" type="application/rss+xml" />
	<link>http://www.incero.com</link>
	<description>Dedicated Server</description>
	<lastBuildDate>Fri, 03 Feb 2012 06:48:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Uploading To FTP Using PHP and CURL</title>
		<link>http://www.incero.com/webdev/uploading-to-ftp-using-php-and-curl</link>
		<comments>http://www.incero.com/webdev/uploading-to-ftp-using-php-and-curl#comments</comments>
		<pubDate>Thu, 15 Oct 2009 23:11:42 +0000</pubDate>
		<dc:creator>Gordon</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://www.incero.com/?p=246</guid>
		<description><![CDATA[An interesting project that I was working on today required grabbing remote files to a server and then pushing them to a remote FTP server. PHP has built in FTP functions, but there are many reasons that you might want to use CURL instead. Here is the code that I used to upload to FTP, [...]]]></description>
			<content:encoded><![CDATA[<p>An interesting project that I was working on today required grabbing remote files to a server and then pushing them to a remote FTP server.</p>
<p>PHP has built in FTP functions, but there are many reasons that you might want to use CURL instead.</p>
<p>Here is the code that I used to upload to FTP, slightly modified for portability:</p>
<p>&lt;?php<br />
$ch = curl_init();<br />
$localfile = &#8220;test.tar&#8221;;<br />
$fp = fopen($localfile, &#8216;r&#8217;);</p>
<p>curl_setopt($ch, CURLOPT_URL, &#8216;ftp://username:password@ftp.domain.com/public_html/filesfromscript/&#8217;.$localfile);<br />
curl_setopt($ch, CURLOPT_UPLOAD, 1);<br />
curl_setopt($ch, CURLOPT_INFILE, $fp);<br />
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));</p>
<p>curl_exec ($ch);<br />
$error_no = curl_errno($ch);<br />
curl_close ($ch);</p>
<p>if ($error_no == 0) {<br />
$message = &#8216;File uploaded successfully.&#8217;;<br />
} else {<br />
$message = &#8220;File upload error: $error_no. Error codes explained here http://curl.haxx.se/libcurl/c/libcurl-errors.html&#8221;;<br />
}<br />
echo $message;<br />
?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.incero.com/webdev/uploading-to-ftp-using-php-and-curl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

