當(dāng)前位置:軟件學(xué)堂 > 資訊首頁 > 網(wǎng)絡(luò)編程 > DIV+CSS > 表單中的文件域file

表單中的文件域file

2012/11/21 19:17:05作者:佚名來源:網(wǎng)絡(luò)

移動端

【實(shí)例介紹】

表單中的文件域file

文件域是由一個文本框和一個“瀏覽”按鈕組成的,用戶可以直接將要上傳給網(wǎng)站的文件的路徑輸人到文本框中,也可以單擊“瀏覽”按鈕進(jìn)行選擇。

【基本語法】

<input  name="文件域的名稱"  type="file"  size="文件域的長度"  maxlength="最多字符數(shù)"/>

【語法介紹】

在表單中插入文件選擇輸人框,只要將<input>標(biāo)記中type屬性值設(shè)為file就可以插人文件選擇輸入框,enctype屬性確保文件采用正確的格式上傳,對于允許文件上傳的表單,不能使用get方法。

【實(shí)例代碼】

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>文件域</title> </head> <body> <table width="100%" cellspacing="0" cellpadding="0">   <tr>     <td><form action="mailto:weixiaofoxw.com" name="form1" method="post" enctype="multipart/form-data"target="_blank" >       <p>   請選擇文件         <input name="fileField" type="file" id="fileField" size="30" maxlength="40" />       </p> </form></td>   </tr> </table> </body> </html>

【代碼分析】

在代碼中,加粗部分的<input name="fileFoeid"type="file"size="30"maXlength="40">標(biāo)記將文件域的名稱設(shè)置為fileField,長度設(shè)置為30,最多字符數(shù)設(shè)置為40,在瀏覽器中瀏覽,效果如圖所示。

文件域file運(yùn)行效果

 【素材及源碼下載】

請點(diǎn)擊:文件域file 下載本實(shí)例相關(guān)素材及源碼

 

標(biāo)簽: 表單  文件域