input type="file"多圖片上傳

來源:互聯網
上載者:User

標籤:erro   any   php   Enctype   print   name   man   pre   multiple   

單個的input type="file"表單也是可以實現多圖片上傳的

代碼如下:

    <form action="manypic.php" method="post" enctype="multipart/form-data">
        <input type="file" name="manypic[]" multiple>
        <input type="submit">
    </form>

這裡要給file表單加上一個multiple屬性 multiple="multiple"也可以

name的屬性值後面要加上[]這樣就可以了  print_r($_FILES)可得到如下資訊:

Array(    [manypic] => Array        (            [name] => Array                (                    [0] => 1.png                    [1] => bg.jpg                )            [type] => Array                (                    [0] => image/png                    [1] => image/jpeg                )            [tmp_name] => Array                (                    [0] => D:\xampp\tmp\php8C53.tmp                    [1] => D:\xampp\tmp\php8C54.tmp                )            [error] => Array                (                    [0] => 0                    [1] => 0                )            [size] => Array                (                    [0] => 44113                    [1] => 325257                )     ))
這裡我上傳的是兩張圖片
另外你也可以提交多個input type="file"上傳域,代碼如下:
    <form action="manypic.php" method="post" enctype="multipart/form-data">
        <input type="file" name="pic1">
        <input type="file" name="pic2">
        <input type="submit">
    </form>
php頁面的print_r的列印結果:
Array(    [pic1] => Array        (            [name] => bg.jpg            [type] => image/jpeg            [tmp_name] => D:\xampp\tmp\phpF661.tmp            [error] => 0            [size] => 325257        )    [pic2] => Array        (            [name] => 1.png            [type] => image/png            [tmp_name] => D:\xampp\tmp\phpF671.tmp            [error] => 0            [size] => 44113        ))
 

input type="file"多圖片上傳

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.