<?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>勿慢牛 &#187; post</title>
	<atom:link href="http://blog.klniu.com/post/tag/post/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.klniu.com</link>
	<description>『勿慢牛个人博客』</description>
	<lastBuildDate>Tue, 22 May 2012 08:52:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>cloudgamer无刷新上传文件的PHP版本修改</title>
		<link>http://blog.klniu.com/post/php-post-files/</link>
		<comments>http://blog.klniu.com/post/php-post-files/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 04:17:05 +0000</pubDate>
		<dc:creator>勿慢牛</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[上传]]></category>
		<category><![CDATA[多文件上传]]></category>

		<guid isPermaLink="false">http://livesdrop.com/post/php-post-files/</guid>
		<description><![CDATA[源文地址 /** 使用本程序之前，请修改php.ini中限制的单个文件最大容量 * upload_max_filesize = 20M //最大文件限制 * post_max_size = 20M //POST接收的最大限制,即所有上传文件的总量 * 并最好与程序中的单个文件限制相同，以免出现验证错误 * 本脚本文件编码为ANSI,建议修改为与其他文件一致的编码 * 请自行修改可以上传的文件类型 * 如果有需要，可以自行修改文件类型的验证方式，读文件开头的2字节，而不是通过后缀名 * @filesource csdn网友mengshan1986提供的php版本 * @changer klniuer * @site http://livesdrop.com **/ ?&#62; $sort=12; $f_type=strtolower(&#34;swf,jpg,rar,zip,7z,iso,gif&#34;);//设置可上传的文件类型 $file_size_max=20*1024*1024;//限制单个文件上传最大容量 $overwrite = 0;//是否允许覆盖相同文件,1:允许,0:不允许 $f_input=&#34;Files&#34;;//设置上传域名称 $_msg = &#34;&#34;; if (isset($_FILES[$f_input])){ //如果文件总大小超过服务器POST限制，文件就没有上传至服务器，foreach就不会执行，返回客户端的会是一个空字符串，此处加入验证 foreach($_FILES[$f_input][&#34;error&#34;] as $key =&#62; $error){ $up_error=&#34;no&#34;; if ($error == UPLOAD_ERR_OK<br/><a class="more" href="http://blog.klniu.com/post/php-post-files/">more...</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cnblogs.com/cloudgamer/archive/2008/10/20/1314766.html" target="_blank">源文地址</a></p>
<pre class="brush:php;">/** 使用本程序之前，请修改php.ini中限制的单个文件最大容量
 * upload_max_filesize = 20M //最大文件限制
 * post_max_size = 20M //POST接收的最大限制,即所有上传文件的总量
 * 并最好与程序中的单个文件限制相同，以免出现验证错误
 * 本脚本文件编码为ANSI,建议修改为与其他文件一致的编码
 * 请自行修改可以上传的文件类型
 * 如果有需要，可以自行修改文件类型的验证方式，读文件开头的2字节，而不是通过后缀名
 * @filesource csdn网友mengshan1986提供的php版本
 * @changer klniuer
 * @site http://livesdrop.com
 **/
?&gt;
$sort=12;
$f_type=strtolower(&quot;swf,jpg,rar,zip,7z,iso,gif&quot;);//设置可上传的文件类型
$file_size_max=20*1024*1024;//限制单个文件上传最大容量
$overwrite = 0;//是否允许覆盖相同文件,1:允许,0:不允许
$f_input=&quot;Files&quot;;//设置上传域名称
$_msg = &quot;&quot;;
if (isset($_FILES[$f_input])){ //如果文件总大小超过服务器POST限制，文件就没有上传至服务器，foreach就不会执行，返回客户端的会是一个空字符串，此处加入验证
  foreach($_FILES[$f_input][&quot;error&quot;] as $key =&gt; $error){
    $up_error=&quot;no&quot;;
    if ($error == UPLOAD_ERR_OK &amp;&amp; is_uploaded_file($_FILES[$f_input][&#39;tmp_name&#39;][$key])){ //加入安全验证
      $f_name=$_FILES[$f_input][&#39;name&#39;][$key];//获取上传源文件名
      $uploadfile=$uploaddir.strtolower(basename($f_name));
      $tmp_type=substr(strrchr($f_name,&quot;.&quot;),1);//获取文件扩展名
      $tmp_type=strtolower($tmp_type);
      if(!stristr($f_type,$tmp_type)){
        $_msg .= &quot;对不起,不能上传&quot;.$tmp_type.&quot;格式文件, &quot;.$f_name.&quot; 文件上传失败!\\n&quot;;
        $up_error=&quot;yes&quot;;
      }elseif ($_FILES[$f_input][&#39;size&#39;][$key]&gt;$file_size_max){
        $_msg .= &quot;对不起,你上传的文件 &quot;.$f_name.&quot; 容量为&quot;.round($_FILES[$f_input][&#39;size&#39;][$key]/1024/1024,1).&quot;MB,大于限制的&quot;. round($file_size_max/1024/1024,1).&quot;MB,上传失败!\\n&quot;;
        $up_error=&quot;yes&quot;;
      }elseif (file_exists($uploadfile) &amp;&amp; !$overwrite){
        $_msg .= &quot;对不起,文件 &quot;.$f_name.&quot; 已经存在,上传失败!\\n&quot;;
        $up_error=&quot;yes&quot;;
      }else{//不需要随机数
        $t=date(&quot;ymdHis&quot;).substr($gettime[0],2,6).$rand;
        $attdir=&quot;file/&quot;;//将文件移至的目录，请根据自己情况修改，相对于该脚本路径
        if(!is_dir($attdir))
          mkdir($attdir);
        $uploadfile=$attdir.$t.&quot;.&quot;.$tmp_type;
        if(($up_error!=&quot;yes&quot;) and (move_uploaded_file($_FILES[$f_input][&#39;tmp_name&#39;][$key], $uploadfile))){
          $_msg .=$f_name.&#39; 上传成功\\n&#39;;
        }else{
          $_msg .=$f_name.&#39; 上传失败\\n&#39;;
        }
      }
    }elseif($error == UPLOAD_ERR_INI_SIZE){//调试使用，防止自己忘记更改upload_max_filesize 最大文件限制
      $msg .= &quot;对不起,文件大小超过服务器限制，请通知管理员。\\n&quot;;
    }else{
      $msg .= &quot;对不起,上传不可意料错误!\\n&quot;;
    }
  }
}else{
  $_msg .= &quot;对不起,文件大小超过限制！\\n&quot;;//如果上传上来的文件为空，则判断文件超过限制大小
}
echo &quot;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--mce:0--&gt;&lt;/script&gt;&quot;;
?&gt;</pre>
<p>完整程序：<a href="http://www.boxcn.net/shared/fur3frt2zd" target="_blank">http://www.boxcn.net/shared/fur3frt2zd</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.klniu.com/post/php-post-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP大文件上传问题</title>
		<link>http://blog.klniu.com/post/php-upload-large-file/</link>
		<comments>http://blog.klniu.com/post/php-upload-large-file/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 02:14:36 +0000</pubDate>
		<dc:creator>勿慢牛</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[大文件上传]]></category>

		<guid isPermaLink="false">http://livesdrop.com/post/php-upload-large-file/</guid>
		<description><![CDATA[PHP上传大文件，除了修改 ; Maximum allowed size for uploaded files. upload_max_filesize = 20M 此外，还应该修改POST的限制 ; Maximum size of POST data that PHP will accept. post_max_size = 20M 而且两个最好一样，就不会出现验证不一致的现象。]]></description>
			<content:encoded><![CDATA[<p>PHP上传大文件，除了修改</p>
<pre class="brush:plain;">; Maximum allowed size for uploaded files.
upload_max_filesize = 20M</pre>
<p>此外，还应该修改POST的限制</p>
<pre class="brush:plain;">; Maximum size of POST data that PHP will accept.
post_max_size = 20M</pre>
<p>而且两个最好一样，就不会出现验证不一致的现象。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.klniu.com/post/php-upload-large-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

