<?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[HTML表单的enctype属性详解]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Mon, 26 Oct 2009 06:04:50 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	Form的表头中有这样一句,&nbsp;&nbsp; <br/>&nbsp;&nbsp;encType=&quot;multipart/form-data&quot;&nbsp;&nbsp; <br/>&nbsp;&nbsp;代表什么意思?删除可以么?&nbsp;&nbsp; <br/>有下面几个值：&nbsp;&nbsp;<br/><br/><div class="code">&lt;form action=&quot;./fileupload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; enctype=&quot;application/x-www-form-urlencoded&quot; enctype=&quot;text/plain&quot;&gt;</div><br/><br/><br/>MIME(多用途网际邮件扩充协议）的编码类型。&nbsp;&nbsp; <br/>&nbsp;&nbsp;脚本里的用法是form.encoding=XXX<br/><br/>MSDN原文，我的翻译能力比较差。&nbsp;&nbsp; <br/><br/><div class="code">&nbsp;&nbsp;Optional.&nbsp;&nbsp; Describes&nbsp;&nbsp; the&nbsp;&nbsp; content&nbsp;&nbsp; of&nbsp;&nbsp; the&nbsp;&nbsp; body&nbsp;&nbsp; section&nbsp;&nbsp; of&nbsp;&nbsp; the&nbsp;&nbsp; message.&nbsp;&nbsp; It&nbsp;&nbsp; can&nbsp;&nbsp; have&nbsp;&nbsp; one&nbsp;&nbsp; of&nbsp;&nbsp; the&nbsp;&nbsp; following&nbsp;&nbsp; values&nbsp;&nbsp; (the&nbsp;&nbsp; default&nbsp;&nbsp; is&nbsp;&nbsp; &quot;text/plain;&nbsp;&nbsp; charset=us-ascii&quot;):&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;text/plain;&nbsp;&nbsp; charset=us-ascii&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;This&nbsp;&nbsp; means&nbsp;&nbsp; that&nbsp;&nbsp; this&nbsp;&nbsp; is&nbsp;&nbsp; a&nbsp;&nbsp; regular&nbsp;&nbsp; message,&nbsp;&nbsp; and&nbsp;&nbsp; the&nbsp;&nbsp; body&nbsp;&nbsp; section&nbsp;&nbsp; contains&nbsp;&nbsp; the&nbsp;&nbsp; message&nbsp;&nbsp; text.&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;Example:&nbsp;&nbsp; Content-Type:&nbsp;&nbsp; text/plain;&nbsp;&nbsp; charset=us-ascii&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;application/x-ms-tnef&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;This&nbsp;&nbsp; means&nbsp;&nbsp; that&nbsp;&nbsp; this&nbsp;&nbsp; is&nbsp;&nbsp; a&nbsp;&nbsp; TNEF&nbsp;&nbsp; message&nbsp;&nbsp; and&nbsp;&nbsp; the&nbsp;&nbsp; body&nbsp;&nbsp; section&nbsp;&nbsp; contains&nbsp;&nbsp; the&nbsp;&nbsp; TNEF&nbsp;&nbsp; data&nbsp;&nbsp; of&nbsp;&nbsp; the&nbsp;&nbsp; message.&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;Example:&nbsp;&nbsp; Content-Type:&nbsp;&nbsp; application/x-ms-tnef&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;multipart/form-data;&nbsp;&nbsp; boundary=boundary-string&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;This&nbsp;&nbsp; means&nbsp;&nbsp; that&nbsp;&nbsp; the&nbsp;&nbsp; form&nbsp;&nbsp; and&nbsp;&nbsp; body&nbsp;&nbsp; section&nbsp;&nbsp; have&nbsp;&nbsp; multiple&nbsp;&nbsp; parts,&nbsp;&nbsp; and&nbsp;&nbsp; each&nbsp;&nbsp; part&nbsp;&nbsp; describes&nbsp;&nbsp; a&nbsp;&nbsp; single&nbsp;&nbsp; form&nbsp;&nbsp; field&nbsp;&nbsp; (name,&nbsp;&nbsp; value,&nbsp;&nbsp; and&nbsp;&nbsp; so&nbsp;&nbsp; on).&nbsp;&nbsp; The&nbsp;&nbsp; boundary-string&nbsp;&nbsp; separates&nbsp;&nbsp; multiple&nbsp;&nbsp; parts&nbsp;&nbsp; in&nbsp;&nbsp; the&nbsp;&nbsp; body&nbsp;&nbsp; section&nbsp;&nbsp; (see&nbsp;&nbsp; Body&nbsp;&nbsp; Section).&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;Example:&nbsp;&nbsp; Content-Type:&nbsp;&nbsp; multipart/form-data;&nbsp;&nbsp; <br/>&nbsp;&nbsp;boundary=xyz12sssdeeggg&nbsp;&nbsp; <br/>&nbsp;&nbsp;<br/>注意：multipart/form-data是上传文件用的，不能删除。</div><br/><br/><br/>用Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型。<br/>下边是说明：<br/>application/x-www-form-urlencoded： 窗体数据被编码为名称/值对。这是标准的编码格式。<br/>multipart/form-data： 窗体数据被编码为一条消息，页上的每个控件对应消息中的一个部分。<br/>text/plain： 窗体数据以纯文本形式进行编码，其中不含任何控件或格式字符。<br/><br/><br/>用于表单里有图片上传。<br/><br/>&lt;form name=&quot;userInfo&quot; method=&quot;post&quot; action=&quot;first_submit.jsp&quot;&nbsp;&nbsp;ENCTYPE=&quot;multipart/form-data&quot;&gt;<br/>表单标签中设置enctype=&quot;multipart/form-data&quot;来确保匿名上载文件的正确编码。<br/>如下：<br/><br/><div class="code"> &lt;tr&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td height=&quot;30&quot; align=&quot;right&quot;&gt;上传企业营业执照图片：&lt;/td&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;INPUT TYPE=&quot;FILE&quot; NAME=&quot;uploadfile&quot; SIZE=&quot;34&quot;&nbsp;&nbsp;ōnChange=&quot;checkimage()&quot;&gt;&lt;/td&gt;<br/>&nbsp;&nbsp;&lt;/tr&gt;</div><br/>就得加ENCTYPE=&quot;multipart/form-data&quot;。<br/><br/><br/>表单中enctype=&quot;multipart/form-data&quot;的意思，是设置表单的MIME编码。默认情况，这个编码格式是 application/x-www-form-urlencoded，不能用于文件上传；只有使用了multipart/form-data，才能完整的传递文件数据，进行下面的操作.<br/>enctype=&#92;&quot;multipart/form-data&#92;&quot;是上传二进制数据; form里面的input的值以2进制的方式传过去。<br/>form里面的input的值以2进制的方式传过去，所以request就得不到值了。 也就是说加了这段代码,用request就会传递不成功,<br/><br/>取表单值加入数据库时，用到下面的：<br/><br/><div class="code"> SmartUpload su = new SmartUpload();//新建一个SmartUpload对象<br/> su.getRequest().getParameterValues();取数组值<br/> su.getRequest().getParameter( );取单个参数单个值</div><br/><br/>当值很多时，使用数组传值是个不错的选择。<br/><br/><div class="code">&lt;input type=&#039;text&#039; name=&#039;formVar&#91;year1&#93;&#039; value=&#039;&#039;&gt;<br/><br/>function toHere($formVar)<br/>&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;echo $formVar&#91;&#039;year1&#039;&#93;;<br/>&#125;</div>
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] HTML表单的enctype属性详解]]></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>