鍍金池/ 問答/PHP/ php接收form-data形式的多文件的問題

php接收form-data形式的多文件的問題

php接收form-data形式的多文件,要求是同一個(gè)key的多文件,采用$_FILTER接收到的數(shù)組,只顯示第一個(gè)文件的信息:

clipboard.png

當(dāng)我采用spring去接受的時(shí)候是都可以接收到的:

clipboard.png

php該如何去接收,還是說php就是做不到?

回答
編輯回答
夏木
<?php
print_r($_FILES);
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
    <input type="file" name="a[]">
    <input type="file" name="a[]">
    <input type="submit" value="123">
</form>
</body>
</html>

這種情況下可以做到,這也是同鍵POST的方法,輸出如下

Array
(
    [a] => Array
        (
            [name] => Array
                (
                    [0] => WX20180507-164412.png
                    [1] => 4271525682162_.pic_hd.jpg
                )

            [type] => Array
                (
                    [0] => image/png
                    [1] => image/jpeg
                )

            [tmp_name] => Array
                (
                    [0] => /private/var/folders/32/85t9_nfn3hl27vm4yxb89c8m0000gn/T/php0pf4YH
                    [1] => /private/var/folders/32/85t9_nfn3hl27vm4yxb89c8m0000gn/T/phpz83Uwi
                )

            [error] => Array
                (
                    [0] => 0
                    [1] => 0
                )

            [size] => Array
                (
                    [0] => 52048
                    [1] => 409694
                )

        )

)


2018年6月29日 04:03
編輯回答
孤影
key:file[]
2017年9月21日 17:47