<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://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://jackxiang.com/post//</link>
<title><![CDATA[[上传文件]记录一下php上传文件及上传文件的临时文件路径的位置配置。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Wed, 31 Mar 2010 04:03:11 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	[root@test user]# php -i&#124;grep upload_tmp_dir <br/>upload_tmp_dir =&gt; no value =&gt; no value<br/>-----------------------------------------------------------------<br/>主要步骤：<br/>1、根据网页中设定位置，自建一个用于存储文件的文件夹cyupload<br/>2、修改cyupload的权限，进入/tmp文件夹中，chmod 777 cyupload -R<br/>3、修改php.ini文件，修改上传文件大小限制。<br/>file_uploads = on ;是否允许通过HTTP上传文件的开关。默认为ON即是开<br/>upload_tmp_dir ;文件上传至服务器上存储临时文件的地方，如果没指定就会用系统默认的临时文件夹<br/>upload_max_filesize = 200m ;望文生意，即允许上传文件大小的最大值。默认为2M<br/>post_max_size = 200m ;指通过表单POST给PHP的所能接收的最大值，包括表单里的所有值。默认为8M<br/>一般地，设置好上述四个参数后，上传&lt;=8M的文件是不成问题，在网络正常的情况下。<br/>但如果要上传&gt;8M的大体积文件，只设置上述四项还一定能行的通。<br/>进一步配置以下的参数<br/>max_execution_time = 0 ;<br/>max_input_time = 2400 ;每个PHP页面接收数据所需的最大时间默认60秒<br/>memory_limit = 256m ;每个PHP页面所吃掉的最大内存，默认8M<br/>把上述参数修改后，在网络所允许的正常情况下，就可以上传大体积文件了<br/>------------------------------------------------------------------------------------------------------------------------------------------------<br/><br/>上传html文件<br/><br/><div class="code"><br/>&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/>&lt;body&gt;<br/>&lt;form enctype=&quot;multipart/form-data&quot; action=&quot;uploadFile.php&quot; method=&quot;post&quot;&gt;<br/>&lt;input type=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot;&nbsp;&nbsp;value=&quot;100000&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;div align=&quot;center&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;center&gt; 请选取文件: <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input name=&quot;file&quot; type=&quot;file&quot; id=&quot;file&quot;/&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;submit&quot; value=&quot;Send File&quot; /&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/center&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br/>&lt;/form&gt;<br/>&lt;/body&gt;<br/>&lt;/html&gt;<br/><br/></div><br/><br/>后台处理文件<br/><br/><div class="code"><br/>&lt;?php<br/>if ((($_FILES&#91;&quot;file&quot;&#93;&#91;&quot;type&quot;&#93; == &quot;image/gif&quot;)&#124;&#124; ($_FILES&#91;&quot;file&quot;&#93;&#91;&quot;type&quot;&#93; == &quot;image/jpeg&quot;)&#124;&#124; ($_FILES&#91;&quot;file&quot;&#93;&#91;&quot;type&quot;&#93; == &quot;image/pjpeg&quot;))&amp;&amp; ($_FILES&#91;&quot;file&quot;&#93;&#91;&quot;size&quot;&#93; &lt; 100000))&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;if ($_FILES&#91;&quot;file&quot;&#93;&#91;&quot;error&quot;&#93; &gt; 0)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Return Code: &quot; . $_FILES&#91;&quot;file&quot;&#93;&#91;&quot;error&quot;&#93; . &quot;&lt;br /&gt;&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;else&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Upload: &quot; . $_FILES&#91;&quot;file&quot;&#93;&#91;&quot;name&quot;&#93; . &quot;&lt;br /&gt;&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Type: &quot; . $_FILES&#91;&quot;file&quot;&#93;&#91;&quot;type&quot;&#93; . &quot;&lt;br /&gt;&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Size: &quot; . ($_FILES&#91;&quot;file&quot;&#93;&#91;&quot;size&quot;&#93; / 1024) . &quot; Kb&lt;br /&gt;&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Temp file: &quot; . $_FILES&#91;&quot;file&quot;&#93;&#91;&quot;tmp_name&quot;&#93; . &quot;&lt;br /&gt;&quot;;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (file_exists(&quot;upload/&quot; . $_FILES&#91;&quot;file&quot;&#93;&#91;&quot;name&quot;&#93;))&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $_FILES&#91;&quot;file&quot;&#93;&#91;&quot;name&quot;&#93; . &quot; already exists. &quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;else&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;move_uploaded_file($_FILES&#91;&quot;file&quot;&#93;&#91;&quot;tmp_name&quot;&#93;,&quot;upload/&quot; . $_FILES&#91;&quot;file&quot;&#93;&#91;&quot;name&quot;&#93;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Stored in: &quot; . &quot;upload/&quot; . $_FILES&#91;&quot;file&quot;&#93;&#91;&quot;name&quot;&#93;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&#125;else&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Invalid file&quot;;<br/>&#125;<br/>?&gt;<br/><br/></div><br/><br/>里面有一个MAX_FILE_SIZE ，MAX_FILE_SIZE这个特性是php提出的，其本意是当用户上传超过该大小时让浏览器端直接作出反应。但这项提议不被两大主流浏览器ie和 firefox支持。在这两个浏览器下测试就会发现，还是要等到上传了MAX_FILE_SIZE的大小。所以并没有起到在浏览器端就阻止用户上传的目的。<br/><br/>另外，记录一下$_FILE[&quot;file&quot;][&quot;error&quot;]的描述：<br/>Error 1：上传文件的大小超过了服务器端设置的大小。<br/>Error 2：上传文件的大小超过了MAX_FILE_SIZE的大小。<br/>来源：<br/>http://ffpan.ctripued.com/2009/12/15/php-upload-file/
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [上传文件]记录一下php上传文件及上传文件的临时文件路径的位置配置。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>