使用 element-ui,上传多图,报错

evilk

PHP version:7.4.26
Workerman version:4.0.33
截图
截图
截图

打印$files
截图

$this->parseFile($file); 这个方法报错了

报错信息


{
"code": 0,
"message": "server error.",
"traces": "ErrorException: Undefined index: tmp_name in /Users/project/vendor/workerman/webman-framework/src/Http/Request.php:134\nStack trace:\n#0 /Users/project/vendor/workerman/webman-framework/src/Http/Request.php(134): {closure}(8, 'Undefined index...', '/Users/...', 134, Array)\n#1 /Users/project/vendor/workerman/webman-framework/src/Http/Request.php(148): Webman\\Http\\Request->parseFile(Array)\n#2 /Users/project/vendor/workerman/webman-framework/src/Http/Request.php(112): Webman\\Http\\Request->parseFiles(Array)\n#3 /Users/project/app/console/controller/StarRedeemProductCategory.php(81): Webman\\Http\\Request->file('file')\n#4 /Users/project/vendor/workerman/webman-framework/src/App.php(251): app\\console\\controller\\StarRedeemProductCategory->update(Object(support\\Request))\n#5 /Users/project/app/console/middleware/Arms.php(25): Webman\\App::Webman\\{closure}(Object(support\\Request))\n#6 /Users/project/vendor/workerman/webman-framework/src/App.php(245): App\\console\\middleware\\Arms->process(Object(support\\Request), Object(Closure))\n#7 /Users/project/app/console/middleware/AuthorizationCheck.php(87): Webman\\App::Webman\\{closure}(Object(support\\Request))\n#8 /Users/project/vendor/workerman/webman-framework/src/App.php(245): app\\console\\middleware\\AuthorizationCheck->process(Object(support\\Request), Object(Closure))\n#9 /Users/project/vendor/workerman/webman-framework/src/App.php(330): Webman\\App::Webman\\{closure}(Object(support\\Request))\n#10 /Users/project/vendor/workerman/webman-framework/src/App.php(147): Webman\\App::findRoute(Object(Workerman\\Connection\\TcpConnection), '/console/star-r...', 'POST/console/st...', Object(support\\Request))\n#11 /Users/project/vendor/workerman/workerman/Connection/TcpConnection.php(638): Webman\\App->onMessage(Object(Workerman\\Connection\\TcpConnection), Object(support\\Request))\n#12 [internal function]: Workerman\\Connection\\TcpConnection->baseRead(Resource id #379, 2, Resource id #379)\n#13 /Users/project/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()\n#14 /Users/project/vendor/workerman/workerman/Worker.php(2431): Workerman\\Events\\Event->loop()\n#15 /Users/project/vendor/workerman/workerman/Worker.php(1555): Workerman\\Worker->run()\n#16 /Users/project/vendor/workerman/workerman/Worker.php(1397): Workerman\\Worker::forkOneWorkerForLinux(Object(Workerman\\Worker))\n#17 /Users/project/vendor/workerman/workerman/Worker.php(1371): Workerman\\Worker::forkWorkersForLinux()\n#18 /Users/project/vendor/workerman/workerman/Worker.php(549): Workerman\\Worker::forkWorkers()\n#19 /Users/project/start.php(108): Workerman\\Worker::runAll()\n#20 {main}"
}

说明一下
上传1张图,没问题
上传多张图,就会报错

971 2 0
2个回答

10bang

config/server.php文件中修改max_package_size,改大点试试

  • evilk 2022-04-20

    跟这个应该没关系
    因为已经是'max_package_size' => 10*1024*1024
    看代码和报错,应该解析files出问题了

  • 10bang 2022-04-20

    看你$files结构,你这样循环肯定有问题了,你打印下$file就知道问题了

  • nitron 2022-04-20

    按我下面说这个改就可以了

nitron

多个文件上传请把前端的 name="file" 改成 name="file[]"

  • evilk 2022-04-20

    谢谢指导
    已解决

  • nitron 2022-04-20

    你即使上传单个文件,,也要记得使用访问多个文件的方式去循环,不要使用原来单文件上传的访问方法

  • evilk 2022-04-20

    谢谢提醒
    非常感谢

年代过于久远,无法发表回答
×
🔝