国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php 使用html5實現多文件上傳實例

2024-05-04 23:51:26
字體:
來源:轉載
供稿:網友

首先向大家介紹一下html5中file的multiple屬性

定義和用法

multiple 屬性規定輸入字段可選擇多個值。如果使用該屬性,則字段可接受多個值。

實例:

<form action="demo_form.asp" method="get"> Select images: <input type="file" name="img" multiple="multiple" /> <input type="submit" /></form>

上面實例中的input file 可接受多個文件上傳字段。

了解了html5中file的multiple屬性,下面我們開始講解使用html5實現多文件上傳。

實例代碼:

html:

<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body><form action="my_parser.php" method="post" enctype="multipart/form-data"> <p><input name="upload[]" type="file" multiple="multiple" /></p> <input type="submit" value="Upload all files"></form></body></html>

php代碼:

for($i=0; $i<count($_FILES['upload']['name']); $i++) { //Get the temp file path $tmpFilePath = $_FILES['upload']['tmp_name'][$i]; //Make sure we have a filepath if ($tmpFilePath != ""){  //Setup our new file path  $newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i];  //Upload the file into the temp dir  if(move_uploaded_file($tmpFilePath, $newFilePath)) {   //Handle other code here  } }}

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 广安市| 剑河县| 东乡族自治县| 屯门区| 景泰县| 玛沁县| 翁源县| 永兴县| 鄂托克前旗| 互助| 莲花县| 双流县| 鹿邑县| 津市市| 马关县| 冷水江市| 武城县| 宿州市| 沁水县| 尼玛县| 海晏县| 雷波县| 鲁山县| 杭州市| 建德市| 新乡县| 伊金霍洛旗| 健康| 孟村| 合山市| 金塔县| 阿拉尔市| 辉县市| 新竹市| 汾西县| 盐津县| 三门县| 临邑县| 克什克腾旗| 西林县| 荃湾区|