<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                介紹了PHP上傳單個文件的過程。但是有些時候,為了使用方便,我們需要滿足同時上傳多個文件的需求。多文件上傳原理相同,不過在處理數據時,需要對上傳數據進行特殊處理。 ~~~ <html> <head> <meta charset="utf-8" /> <title>單文件上傳</title> </head> <body> <form action="morefile.php" method="post" enctype="multipart/form-data"> <input type="file" name="file[]"> <input type="file" name="file[]"> <input type="submit" value="上傳"> </form> </body> </html> ~~~ 這里是一個簡易的上傳頁面,form表單同時提交了兩個文件。我們 可以通過這個頁面提交內容。 注意: 1. input type="file" name="file[]"與之前相比file后多加了一個中括號 2. 寫了2個或者多個input type="file" name="file[]" 我們使用 $_FILES 來接收文件信息,打印并查看數組: ~~~ <?php var_dump($_FILES); //打印$_FILES查看數組結構 ?> ~~~ 數組結構如下 ~~~ array (size=1) 'file' => array (size=5) 'name' => array (size=2) //文件名 0 => string 'psu.jpg' (length=7) 1 => string 'qwe.jpg' (length=7) //文件mime類型 'type' => array (size=2) 0 => string 'image/jpeg' (length=10) 1 => string 'image/jpeg' (length=10) //緩存文件 'tmp_name' => array (size=2) 0 => string 'E:\wamp\tmp\phpF6D5.tmp' (length=23) 1 => string 'E:\wamp\tmp\phpF6F5.tmp' (length=23) //文件錯誤信息 'error' => array (size=2) 0 => int 0 1 => int 0 //文件大小 'size' => array (size=2) 0 => int 225824 1 => int 151651 ~~~ 我們可以看到,兩個文件被存儲在一個數組中,鍵名和上傳單文件是相同。所以,需要我們用for()循環,來分別取出兩個文件的需要用到的數據。 在$_FILES中同時保存了兩個文件的數據,我們需要使用一個簡單的循環,來讀取單個文件的信息,并將文件移動到我們想要放的位置。 ~~~ for ($i=0; $i < count($_FILE['file']['name']); $i++) { /* 用is_uploaded_file()函數判斷是上傳文件 并且沒有出現錯 */ if(is_uploaded_file($_FILEs['file']['tmp_name'][$i]) && $_FILEs['file']['error'][$i] == 0){ if(move_uploaded_file($_FILEs['file']['tmp_name'][$i],'upload/'.$_FILE['file']['name'][$i])){ //用move_uploaded_file()函數移動文件到指定的位置并使用文件原名 echo "上傳成功"; }else{ echo '上傳失敗'; } }else{ echo '上傳失敗'; } } ~~~ 詳細的判斷過程,參見單文件上傳,這里只做了基本的判斷,并沒有對文件的大小及格式提醒。 請按照業務,自行判斷文件大小及格式進行錯誤提醒。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看