Open
Description
thinkphp5.1.34 使用 Request::file() 获取上传的全部文件, 框架抛出异常,但是使用$_POST可以获取到正确的参数,异常如下:
[8] ErrorException in Request.php line 1214
未定义数组下标: 0
foreach ($files as $key => $file) {
if ($file instanceof File) {
$array[$key] = $file;
} elseif (is_array($file['name'])) {
$item = [];
$keys = array_keys($file);
$count = count($file['name']);
for ($i = 0; $i < $count; $i++) {
if ($file['error'][$i] > 0) {
if ($name == $key) {
$this->throwUploadFileError($file['error'][$i]);
} else {
continue;
}
}
$temp['key'] = $key;
请求参数如下:
curl -X POST
http://www.tp51.local/file/file/save
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
-F 'img[data1]=@C:\Users\Public\Pictures\Sample Pictures\Desert.jpg'
-F 'img[data2]=@C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg'
Metadata
Metadata
Assignees
Labels
No labels