第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用PHP上傳多個文件

如何使用PHP上傳多個文件

PHP
手掌心 2021-04-27 17:53:21
我不知道如何修改以下代碼,以使其通過選擇一次上傳多個文件。通過以下代碼,我可以一次上傳一個文件。只是希望通過此代碼對其進行修改,不僅我要上傳文件,還要在同一頁面上顯示所有已上傳的文件,以供下載和刪除。    <html>    <title>Brief upload</title>    <link href="globe.png" rel="shortcut icon">    <?php    date_default_timezone_set("Asia/Calcutta");    //echo date_default_timezone_get();    ?>    <?php    $conn=new PDO('mysql:host=localhost; dbname=deu', 'root', '') or die(mysql_error());    if(isset($_POST['submit'])!=""){      $name=$_FILES['photo']['name'];      $size=$_FILES['photo']['size'];      $type=$_FILES['photo']['type'];      $temp=$_FILES['photo']['tmp_name'];      $date = date('Y-m-d H:i:s');      $caption1=$_POST['caption'];      $link=$_POST['link'];      move_uploaded_file($temp,"files/".$name);    $query=$conn->query("INSERT INTO upload (name,date) VALUES ('$name','$date')");    if($query){    header("location:index.php");    }    else{    die(mysql_error());    }    }    ?>    <html>    <body>    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">    <link rel="stylesheet" type="text/css" href="css/DT_bootstrap.css">    <link rel="stylesheet" type="text/css" href="css/font-awesome.css">    <link rel="stylesheet" href="css/bootstrap.min.css">    <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css"/>    </head>    <script src="js/jquery.js" type="text/javascript"></script>    <script src="js/bootstrap.js" type="text/javascript"></script>    <script type="text/javascript" charset="utf-8" language="javascript" src="js/jquery.dataTables.js"></script>    <script type="text/javascript" charset="utf-8" language="javascript" src="js/DT_bootstrap.js"></script>    <?php include('dbcon.php'); ?>    <style>   
查看完整描述

1 回答

?
婷婷同學_

TA貢獻1844條經(jīng)驗 獲得超8個贊

您可以通過這種方式上傳多個文件

  1. 輸入字段必須定義為數(shù)組,即 images[]

  2. 它應該定義為 multiple="multiple"

<input name="images[]" type="file" multiple="multiple" />


// Count # of uploaded files in array

$total = count($_FILES['images']['name']);


// Loop through each file

for( $i=0 ; $i < $total ; $i++ ) {


  //Get the temp file path

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


  //Make sure we have a file path

  if ($tmpFilePath != ""){

  //Setup our new file path

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


//Upload the file into the temp dir

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


  //Handle other code here


 }

 }

}

有關更多詳細信息,PHP多次上傳


查看完整回答
反對 回復 2021-05-07
  • 1 回答
  • 0 關注
  • 194 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號