抄自這里
form的enctype屬性為編碼方式澈段,常用有兩種:application/x-www-form-urlencoded
和multipart/form-data
亿乳。
默認(rèn)為application/x-www-form-urlencoded
令宿。 當(dāng)action為get時(shí)候狂丝,瀏覽器用x-www-form-urlencoded的編碼方式把form數(shù)據(jù)轉(zhuǎn)換成一個(gè)字串(name1=value1&name2=value2...)管嬉,然后把這個(gè)字串a(chǎn)ppend到url后面地技,用?分割袁翁,加載這個(gè)新的url柴底。 當(dāng)action為post時(shí)候,瀏覽器把form數(shù)據(jù)封裝到http body中粱胜,然后發(fā)送到server柄驻。
如果沒(méi)有type=file的控件,用默認(rèn)的application/x-www-form-urlencoded
就可以了焙压。 但是如果有type=file的話鸿脓,就要用到multipart/form-data
了。瀏覽器會(huì)把整個(gè)表單以控件為單位分割涯曲,并為每個(gè)部分加上Content-Disposition(form-data或者file),Content-Type(默認(rèn)為text/plain),name(控件name)等信息野哭,并加上分割符(boundary)。
更詳細(xì)的