Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文件上传提示 ErrorException in Request.php line 1214 未定义数组下标: 0 #890

Open
591776998 opened this issue Feb 18, 2019 · 0 comments

Comments

@591776998
Copy link

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant