<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[[实践OK]用 curl上传文件，Linux的Shell下用CURL上传文件实例于php://input的接收，PHP扩展用Curl上传文件。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Thu, 18 Sep 2008 05:32:56 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	上传文件的curl参数是-T：<br/><textarea name="code" class="php" rows="15" cols="100">
 -T/--upload-file &lt;file&gt; Transfer &lt;file&gt; to remote site
&nbsp;&nbsp;&nbsp;&nbsp;--url &lt;URL&gt;&nbsp;&nbsp;&nbsp;&nbsp; Spet URL to work with
</textarea><br/><br/>1）上传uploadContents.txt文件内容：<br/>this is upload file by php.<br/><br/>2）接收代码：<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
// Example to parse &quot;PUT&quot; requests
$contents = file_get_contents(&#039;php://input&#039;);
echo $contents;echo &quot;&#92;n&quot;;
//parse_str(file_get_contents(&#039;php://input&#039;), $_PUT);
// The result
//print_r($_PUT);
?&gt;
</textarea><br/>来自plupload里通过swf一个文件小于自己配置的10M时就一次性上传的协议，Flash是这样进行提交的：<br/>Content-Disposition: form-data; name=&quot;name&quot; p18e57aitdkecp1vbe40lccu4.zip<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XXXXXXXXXX 文件内容<br/>3）运行打印：<br/>C:&#92;Users&#92;admin&gt;curl -d&quot;dfd=php://input can not read here&#039;s contents&quot;&nbsp;&nbsp;-T&quot;D:&#92;uploadContents.txt&quot; http://localhost/php_input.php<br/>this is upload file by php.<br/><br/>4）说明，对于-d参数，其PHP的php://input是不会接收的，其接收的是二进制流，用$_POST,是可以打印出来的(但通过linux下的shell同时发送-d -T是只能打出-T内容)。<br/><br/>如，通过给PHP里的php://input上传一个文件，发现这个文件不能被读取到，说明它就是只能接二进制文件的，如下：<br/>C:&#92;Users&#92;admin&gt;curl -F upload_file=@D:&#92;uploadContents.txt -F &quot;name=yangqi&quot; http://localhost/php_input.php<br/> -F/--form &lt;name=content&gt; Specify HTTP multipart POST data (H)<br/>&nbsp;&nbsp;&nbsp;&nbsp;--form-string &lt;name=string&gt; Specify HTTP multipart POST data (H)<br/>Array<br/>(<br/>&nbsp;&nbsp;&nbsp;&nbsp;[upload_file] =&gt; Array<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[name] =&gt; uploadContents.txt<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[type] =&gt; text/plain<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[tmp_name] =&gt; D:&#92;wamp&#92;tmp&#92;phpDAB9.tmp<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[error] =&gt; 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[size] =&gt; 76<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br/><br/>)<br/>Array<br/>(<br/>&nbsp;&nbsp;&nbsp;&nbsp;[name] =&gt; yangqi<br/>)<br/><br/>接收代码如下：<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;// Example to parse &quot;PUT&quot; requests
&nbsp;&nbsp;&nbsp;&nbsp;$contents = file_get_contents(&#039;php://input&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;echo $contents;
&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&#92;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;print_r($_FILES);
&nbsp;&nbsp;&nbsp;&nbsp;print_r($_POST);
?&gt;
</textarea><br/>_______________________分块传时是这样的_______________________________<br/>Content-Disposition: form-data; name=&quot;name&quot;&nbsp;&nbsp;p18e57g55eof2u6k19971jo1cvu8.zip<br/>Content-Disposition: form-data; name=&quot;chunk&quot;&nbsp;&nbsp;0<br/>Content-Disposition: form-data; name=&quot;chunks&quot;&nbsp;&nbsp;5<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 上传文件内容XXXX<br/>______________________________________________________________________________________<br/>更多参考如下Url：http://jackxiang.com/post/6421/<br/>curl -F userfile=@/usr/local/apache2/conf/httpd.conf http://app.space.sina.com.cn/upload.php // 上传<br/>curl -d &quot;get=123&amp;post=222&quot; http://app.space.sina.com.cn/get_post.php&nbsp;&nbsp; //post<br/>curl http://app.space.sina.com.cn/get_post.php?&quot;post=888&amp;get=1212&quot;&nbsp;&nbsp; //引号引起来get<br/>加上访问时间（注意：这儿的upload_file相当于控件html file的name）：<br/>curl -s -w &#039;%&#123;time_connect&#125;:%&#123;time_starttransfer&#125;:%&#123;time_total&#125;&#039; -F upload_file=@/home/xiangdong/uploadFileTest/buer.rmvb &quot;http://up.xiyou.cntv.cn/uptest.php&quot;<br/><br/>0.001:0.001:14.458<br/><br/><div class="code">&lt;?php<br/>$uploaddir = &#039;/home/xiangdong2/pic_all_here&#039;;<br/>$uploadfile = $uploaddir . basename($_FILES&#91;&#039;userfile&#039;&#93;&#91;&#039;name&#039;&#93;);<br/>if (move_uploaded_file($_FILES&#91;&#039;userfile&#039;&#93;&#91;&#039;tmp_name&#039;&#93;, $uploadfile))<br/>&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;File is valid, and was successfully uploaded.&#92;n&quot;;<br/>&#125; else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Possible file upload attack!&#92;n&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &#039;Here is some more debugging info:&#039;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print_r($_FILES);<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#125;<br/><br/>?&gt;</div><br/><br/><br/><br/><br/><br/><div class="code">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<br/>&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br/>&lt;head&gt;<br/>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;<br/>&lt;title&gt;upload file&lt;/title&gt;<br/>&lt;/head&gt;<br/><br/>&lt;body&gt;<br/>&lt;form id=&quot;form1&quot; name=&quot;form1&quot; enctype=&quot;multipart/form-data&quot; method=&quot;post&quot; action=&quot;http://app.space.sina.com.cn/upload.php&quot;&gt;<br/>&nbsp;&nbsp;&lt;label&gt;<br/>&nbsp;&nbsp;&lt;input type=&quot;file&quot; name=&quot;userfile&quot; id=&quot;fileField&quot; /&gt;<br/>&nbsp;&nbsp;&lt;/label&gt;<br/>&nbsp;&nbsp;&lt;label&gt;<br/>&nbsp;&nbsp;&lt;input type=&quot;submit&quot; name=&quot;button&quot; id=&quot;button&quot; value=&quot;upload&quot; /&gt;<br/>&nbsp;&nbsp;&lt;/label&gt;<br/>&lt;/form&gt;<br/>&lt;/body&gt;<br/>&lt;/html&gt;</div><br/><br/><br/><br/><div class="code">&lt;?php<br/>if(isset($_REQUEST&#91;&#039;get&#039;&#93;))<br/>&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$get =$_REQUEST&#91;&#039;get&#039;&#93;;<br/>&#125;else&#123;<br/>$get=&quot;get&quot;;<br/><br/>&#125;<br/>if(isset($_REQUEST&#91;&#039;post&#039;&#93;))<br/>&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$post =$_REQUEST&#91;&#039;post&#039;&#93;;<br/>&#125;else&#123;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;$post=&quot;post&quot;;<br/>&#125;<br/><br/>echo &quot;get=&quot;.$get.&quot;&#92;n&quot;;<br/>echo &quot;post=&quot;.$post.&quot;&#92;n&quot;;<br/><br/>?&gt;</div><br/><br/><br/><br/><br/><br/><br/><br/>PHP扩展用Curl上传文件：<br/><br/><textarea name="code" class="php" rows="15" cols="100">
$str =&nbsp;&nbsp; $res[&#039;str&#039;];
$iplist = $res[&#039;iplist&#039;];
$did = $res[&#039;did&#039;];
$handle = fopen(&quot;/tmp/hostname.txt&quot;,&quot;w&quot;);
fwrite($handle,$str);
fclose($handle);
$ret = curlUpload(&quot;/tmp/hostname.txt&quot;,&quot;http://jackxiang.com/php/uploadHostName.php&quot;);
$retary = json_decode($ret,true);
if($retary[&#039;code&#039;]==-1)&#123;
&nbsp;&nbsp;die(&quot;&#123;code:1,msg:&#92;&quot;上传hostname失败&#92;&quot;&#125;&quot;);
&#125;
@unlink(&quot;/tmp/hostname.txt&quot;);
</textarea><br/>调用的实际上传：<br/><textarea name="code" class="php" rows="15" cols="100">
/**
 * curl 上传
 */
function curlUpload($filename,$url)&#123;
&nbsp;&nbsp;$fields[&#039;software&#039;] = &#039;@&#039;.$filename;
&nbsp;&nbsp;$fields[&#039;phpcallback&#039;] = true;
&nbsp;&nbsp;$ch = curl_init();
&nbsp;&nbsp;curl_setopt($ch, CURLOPT_URL, $url );
&nbsp;&nbsp;curl_setopt($ch, CURLOPT_POST, true );
&nbsp;&nbsp;curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
&nbsp;&nbsp;curl_setopt($ch, CURLOPT_POSTFIELDS, $fields );
&nbsp;&nbsp;$content =&nbsp;&nbsp;curl_exec( $ch );
&nbsp;&nbsp;curl_close($ch);
&nbsp;&nbsp;return $content;
&#125;
</textarea><br/><br/><br/>附录Flash进行多文件上传时的代码，在单文件时是通过php:input，而多文件时是_FILES进行分块上传的，upload.php里的代码如下：<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
/**
 * upload.php
 *
 * Copyright 2009, Moxiecode Systems AB
 * Released under GPL License.
 *
 * License: http://www.plupload.com/license
 * Contributing: http://www.plupload.com/contributing
 */

// HTTP headers for no cache etc
header(&quot;Expires: Mon, 26 Jul 1997 05:00:00 GMT&quot;);
header(&quot;Last-Modified: &quot; . gmdate(&quot;D, d M Y H:i:s&quot;) . &quot; GMT&quot;);
header(&quot;Cache-Control: no-store, no-cache, must-revalidate&quot;);
header(&quot;Cache-Control: post-check=0, pre-check=0&quot;, false);
header(&quot;Pragma: no-cache&quot;);

// Settings
$targetDir = ini_get(&quot;upload_tmp_dir&quot;) . DIRECTORY_SEPARATOR . &quot;plupload&quot;;
//$targetDir = &#039;uploads&#039;;

$cleanupTargetDir = true; // Remove old files
$maxFileAge = 5 * 3600; // Temp file age in seconds

// 5 minutes execution time
@set_time_limit(5 * 60);

// Uncomment this one to fake upload time
// usleep(5000);

// Get parameters
$chunk = isset($_REQUEST[&quot;chunk&quot;]) ? intval($_REQUEST[&quot;chunk&quot;]) : 0;
$chunks = isset($_REQUEST[&quot;chunks&quot;]) ? intval($_REQUEST[&quot;chunks&quot;]) : 0;
$fileName = isset($_REQUEST[&quot;name&quot;]) ? $_REQUEST[&quot;name&quot;] : &#039;&#039;;

// Clean the fileName for security reasons
$fileName = preg_replace(&#039;/[^&#92;w&#92;._]+/&#039;, &#039;_&#039;, $fileName);

// Make sure the fileName is unique but only if chunking is disabled
if ($chunks &lt; 2 &amp;&amp; file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) &#123;
&nbsp;&nbsp;$ext = strrpos($fileName, &#039;.&#039;);
&nbsp;&nbsp;$fileName_a = substr($fileName, 0, $ext);
&nbsp;&nbsp;$fileName_b = substr($fileName, $ext);

&nbsp;&nbsp;$count = 1;
&nbsp;&nbsp;while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . &#039;_&#039; . $count . $fileName_b))
&nbsp;&nbsp;&nbsp;&nbsp;$count++;

&nbsp;&nbsp;$fileName = $fileName_a . &#039;_&#039; . $count . $fileName_b;
&#125;

$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;

// Create target dir
if (!file_exists($targetDir))
&nbsp;&nbsp;@mkdir($targetDir);

// Remove old temp files
if ($cleanupTargetDir) &#123;
&nbsp;&nbsp;if (is_dir($targetDir) &amp;&amp; ($dir = opendir($targetDir))) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;while (($file = readdir($dir)) !== false) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Remove temp file if it is older than the max age and is not the current file
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (preg_match(&#039;/&#92;.part$/&#039;, $file) &amp;&amp; (filemtime($tmpfilePath) &lt; time() - $maxFileAge) &amp;&amp; ($tmpfilePath != &quot;&#123;$filePath&#125;.part&quot;)) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@unlink($tmpfilePath);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;closedir($dir);
&nbsp;&nbsp;&#125; else &#123;
&nbsp;&nbsp;&nbsp;&nbsp;die(&#039;&#123;&quot;jsonrpc&quot; : &quot;2.0&quot;, &quot;error&quot; : &#123;&quot;code&quot;: 100, &quot;message&quot;: &quot;Failed to open temp directory.&quot;&#125;, &quot;id&quot; : &quot;id&quot;&#125;&#039;);
&nbsp;&nbsp;&#125;
&#125;

// Look for the content type header
if (isset($_SERVER[&quot;HTTP_CONTENT_TYPE&quot;]))
&nbsp;&nbsp;$contentType = $_SERVER[&quot;HTTP_CONTENT_TYPE&quot;];

if (isset($_SERVER[&quot;CONTENT_TYPE&quot;]))
&nbsp;&nbsp;$contentType = $_SERVER[&quot;CONTENT_TYPE&quot;];

// Handle non multipart uploads older WebKit versions didn&#039;t support multipart in HTML5
if (strpos($contentType, &quot;multipart&quot;) !== false) &#123;
&nbsp;&nbsp;if (isset($_FILES[&#039;file&#039;][&#039;tmp_name&#039;]) &amp;&amp; is_uploaded_file($_FILES[&#039;file&#039;][&#039;tmp_name&#039;])) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;// Open temp file
&nbsp;&nbsp;&nbsp;&nbsp;$out = @fopen(&quot;&#123;$filePath&#125;.part&quot;, $chunk == 0 ? &quot;wb&quot; : &quot;ab&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;if ($out) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Read binary input stream and append it to temp file
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$in = @fopen($_FILES[&#039;file&#039;][&#039;tmp_name&#039;], &quot;rb&quot;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($in) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ($buff = fread($in, 4096))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fwrite($out, $buff);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(&#039;&#123;&quot;jsonrpc&quot; : &quot;2.0&quot;, &quot;error&quot; : &#123;&quot;code&quot;: 101, &quot;message&quot;: &quot;Failed to open input stream.&quot;&#125;, &quot;id&quot; : &quot;id&quot;&#125;&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@fclose($in);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@fclose($out);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@unlink($_FILES[&#039;file&#039;][&#039;tmp_name&#039;]);
&nbsp;&nbsp;&nbsp;&nbsp;&#125; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(&#039;&#123;&quot;jsonrpc&quot; : &quot;2.0&quot;, &quot;error&quot; : &#123;&quot;code&quot;: 102, &quot;message&quot;: &quot;Failed to open output stream.&quot;&#125;, &quot;id&quot; : &quot;id&quot;&#125;&#039;);
&nbsp;&nbsp;&#125; else
&nbsp;&nbsp;&nbsp;&nbsp;die(&#039;&#123;&quot;jsonrpc&quot; : &quot;2.0&quot;, &quot;error&quot; : &#123;&quot;code&quot;: 103, &quot;message&quot;: &quot;Failed to move uploaded file.&quot;&#125;, &quot;id&quot; : &quot;id&quot;&#125;&#039;);
&#125; else &#123;
&nbsp;&nbsp;// Open temp file
&nbsp;&nbsp;$out = @fopen(&quot;&#123;$filePath&#125;.part&quot;, $chunk == 0 ? &quot;wb&quot; : &quot;ab&quot;);
&nbsp;&nbsp;if ($out) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;// Read binary input stream and append it to temp file
&nbsp;&nbsp;&nbsp;&nbsp;$in = @fopen(&quot;php://input&quot;, &quot;rb&quot;);

&nbsp;&nbsp;&nbsp;&nbsp;if ($in) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ($buff = fread($in, 4096))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fwrite($out, $buff);
&nbsp;&nbsp;&nbsp;&nbsp;&#125; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(&#039;&#123;&quot;jsonrpc&quot; : &quot;2.0&quot;, &quot;error&quot; : &#123;&quot;code&quot;: 101, &quot;message&quot;: &quot;Failed to open input stream.&quot;&#125;, &quot;id&quot; : &quot;id&quot;&#125;&#039;);

&nbsp;&nbsp;&nbsp;&nbsp;@fclose($in);
&nbsp;&nbsp;&nbsp;&nbsp;@fclose($out);
&nbsp;&nbsp;&#125; else
&nbsp;&nbsp;&nbsp;&nbsp;die(&#039;&#123;&quot;jsonrpc&quot; : &quot;2.0&quot;, &quot;error&quot; : &#123;&quot;code&quot;: 102, &quot;message&quot;: &quot;Failed to open output stream.&quot;&#125;, &quot;id&quot; : &quot;id&quot;&#125;&#039;);
&#125;

// Check if file has been uploaded
if (!$chunks &#124;&#124; $chunk == $chunks - 1) &#123;
&nbsp;&nbsp;// Strip the temp .part suffix off
&nbsp;&nbsp;rename(&quot;&#123;$filePath&#125;.part&quot;, $filePath);
&#125;

die(&#039;&#123;&quot;jsonrpc&quot; : &quot;2.0&quot;, &quot;result&quot; : null, &quot;id&quot; : &quot;id&quot;&#125;&#039;);

</textarea><br/><br/>来自：http://www.oschina.net/code/snippet_12_5808
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践OK]用 curl上传文件，Linux的Shell下用CURL上传文件实例于php://input的接收，PHP扩展用Curl上传文件。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>