<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></title> 
<link>http://www.bizeway.net/index.php</link> 
<description><![CDATA[网务通 - 网务公司发展之路]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></copyright>
<item>
<link>http://www.bizeway.net/read.php?399</link>
<title><![CDATA[被人遗忘的MAX_FILE_SIZE文件上传限制大小参数]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[PHP]]></category>
<pubDate>Thu, 15 Jan 2009 06:25:05 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?399</guid> 
<description>
<![CDATA[ 
	　　在文件上传中，我们经常会要求显示用户上传文件大小，超过上传限制的文件就会不允许用户上传。虽然我们可以用程序去判断上传文件是否超过限制，但是其实我们的PHP程序是无法判断用户本地文件大小的。所以等到我们的PHP来判断文件大小的时候，那个文件其实已经上传到服务器了。这时候再判断超过限制了，不允许上传。可就有点马后炮了。<br/>　　那么有没有办法在文件上传之前就判断将要上传的文件是否超过限制，不允许用户上传呢？答案是肯定的，只是经常被人们遗忘而已。这个办法不是在程序上解决的。而是使用html的标签解决的。<br/><br/><div class="code">&lt;input type=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;30000&quot; /&gt;</div><br/>将这段代码一定要放到文件提交框之前，就可以了。给个完整的例子如下：<br/><div class="code">&lt;form enctype=&quot;multipart/form-data&quot; action=&quot;__URL__&quot; method=&quot;POST&quot;&gt;<br/> &nbsp; &nbsp;&lt;!-- MAX_FILE_SIZE must precede the file input field --&gt;<br/> &nbsp; &nbsp;&lt;input type=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;30000&quot; /&gt;<br/> &nbsp; &nbsp;&lt;!-- Name of input element determines name in $_FILES array --&gt;<br/> &nbsp; &nbsp;Send this file: &lt;input name=&quot;userfile&quot; type=&quot;file&quot; /&gt;<br/> &nbsp; &nbsp;&lt;input type=&quot;submit&quot; value=&quot;Send File&quot; /&gt;<br/>&lt;/form&gt;</div><br/><br/>使用了这个隐藏域之后，可以在用户提交之后，文件上传之前就进行限制判断，超过限制，马上做出$_FILES['error'] =2的错误。这样就可以避免等一个大文件传上服务器以后才发现超过限制了。这样既浪费了用户的表情，也浪费了我们的贷款。所以在这里，我ArthurXF强烈建议大家在做文件上传的时候加上上面的限制，以提高用户的体验！<br/>Tags - <a href="tag.php?tag=html" rel="tag">html</a> , <a href="tag.php?tag=php" rel="tag">php</a> , <a href="tag.php?tag=%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0" rel="tag">文件上传</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?399&amp;guid=0#topreply</link>
<title><![CDATA[[评论] 被人遗忘的MAX_FILE_SIZE文件上传限制大小参数]]></title> 
<author>Cissy &lt;tyoukarin@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 26 Mar 2009 15:29:22 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?399&amp;guid=0#topreply</guid> 
<description>
<![CDATA[ 
	楼主好。<br/>MAX_FILE_SIZE这个特性是php提出的，其本意是当用户上传超过该大小时让浏览器端直接作出反应。但这项提议不被两大主流浏览器ie和firefox支持。在这两个浏览器下测试就会发现，还是要等到上传了MAX_FILE_SIZE的大小（甚至更多，因为php的缓冲大小是5k，就是说可能最多会多传5k）才能知道超过了。<br/>所以并不是“被人遗忘的”，也提高不了用户的体验。
]]>
</description>
</item>
</channel>
</rss>