色www,五月婷婷深爱五月,午夜国产一级片,色噜噜综合,国产大胸无码视频,清纯美女被操黄网站在线观看,波多野结衣av高清一区二区三区

php使用html5實(shí)現(xiàn)多文件上傳實(shí)例

時(shí)間:2025-09-10 18:10:30 php語言

php使用html5實(shí)現(xiàn)多文件上傳實(shí)例

  在html沒有出來之前,要實(shí)現(xiàn)php多文件上傳比較麻煩,需要在form表單里面添加多個(gè)input file域。html5發(fā)布以后,我們可以使用input file的html5屬性multiple來實(shí)現(xiàn)多文件上傳,需要的朋友可以參考下。

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

  定義和用法:

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

  實(shí)例:

  <form action="demo_form.asp" method="get">

  Select images: <input type="file" name="img" multiple="multiple" />

  <input type="submit" />

  </form>

  上面實(shí)例中的input file 可接受多個(gè)文件上傳字段。

  了解了html5中file的multiple屬性,下面我們開始講解使用html5實(shí)現(xiàn)多文件上傳。

  實(shí)例代碼:

  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++) {

  /pic/p>

  $tmpFilePath = $_FILES['upload']['tmp_name'][$i];

  /pic/p>

  if ($tmpFilePath != ""){

  /pic/p>

  $newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i];

  /pic/p>

  if(move_uploaded_file($tmpFilePath, $newFilePath)) {

  /pic/p>

  }

  }

  }

  最后,非常感謝大家的閱讀,希望能幫助到大家!

【php使用html5實(shí)現(xiàn)多文件上傳實(shí)例】相關(guān)文章:

PHP實(shí)現(xiàn)文件上傳和多文件上傳01-19

php實(shí)現(xiàn)通過ftp上傳文件06-28

jQuery Mobile + PHP實(shí)現(xiàn)文件上傳12-08

php多個(gè)文件及圖片上傳實(shí)例詳解01-23

php中使用jquery uploadify進(jìn)行多圖片上傳實(shí)例02-11

用PHP實(shí)現(xiàn)文件上傳二法12-20

php實(shí)現(xiàn)文件上傳及頭像預(yù)覽功能11-04

PHP實(shí)現(xiàn)大文件上傳源代碼11-07

PHP圖片文件怎么上傳實(shí)現(xiàn)代碼01-25