首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
上传159K以上大文件失败
### 问题描述 上传文件时,159k以上大小的问题无法上传,无返回值。159k及以下大小的文件可以正常上传。NGINX、PHP上传文件大小限制是2M,设置了swoole的package_max_length。 ### Swoole版本,PHP版本,以及操作系统版本信息 swoole4.5.1,PHP7.2,Ubuntu18.04 ### 相关代码 ```php Coroutine::set(['hook_flags'=>SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL]); $http = new Swoole\Http\Server("0.0.0.0", 9501); $http->set(array('package_max_length'=>1024 * 1024 * 2)); $http->on('workerStart', function (Server $server, $http->on('request', function (Request $request, Response $response) { $response->header('Content-Type', 'application/json'); ob_start(); $response->end((new App())->run($request, $response)); ob_end_clean(); }); $http->start(); $file = files() ['myfile']; $file_name = $file ['name']; $file_tmp_path = $file ['tmp_name']; $uplod_path = ROOT . '/upload/'; if (! file_exists($uplod_path)) { mkdir($uplod_path); } $res = move_uploaded_file($file_tmp_path, $uplod_path . $file_name); ``` ### 你期待的结果是什么?实际看到的错误信息又是什么? swoole没有显示错误信息。 上传159k以上文件,一段时间后,显示404错误
发布于6年前 · 11 次浏览 · 来自
提问
凌霄一宇a
### 问题描述 上传文件时,159k以上大小的问题无法上传,无返回值。159k及以下大小的文件可以正常上传。NGINX、PHP上传文件大小限制是2M,设置了swoole的package_max_length。 ### Swoole版本,PHP版本,以及操作系统版本信息 swoole4.5.1,PHP7.2,Ubuntu18.04 ### 相关代码 ```php Coroutine::set(['hook_flags'=>SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL]); $http = new Swoole\Http\Server("0.0.0.0", 9501); $http->set(array('package_max_length'=>1024 * 1024 * 2)); $http->on('workerStart', function (Server $server, $http->on('request', function (Request $request, Response $response) { $response->header('Content-Type', 'application/json'); ob_start(); $response->end((new App())->run($request, $response)); ob_end_clean(); }); $http->start(); $file = files() ['myfile']; $file_name = $file ['name']; $file_tmp_path = $file ['tmp_name']; $uplod_path = ROOT . '/upload/'; if (! file_exists($uplod_path)) { mkdir($uplod_path); } $res = move_uploaded_file($file_tmp_path, $uplod_path . $file_name); ``` ### 你期待的结果是什么?实际看到的错误信息又是什么? swoole没有显示错误信息。 上传159k以上文件,一段时间后,显示404错误
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2020-06-08
凌霄一宇a
swoole没有输出错误信息,超时后404
赞
0
回复
2020-06-08
鲁飞
直接这样试下有没有问题。 ```php $http = new Swoole\Http\Server("0.0.0.0", 9501); $http->set(array('package_max_length'=>1024 * 1024 * 2)); $http->on('request', function ($request, $response) { $files = $request->files; $file = $files['myfile']; $file_name = $file['name']; $file_tmp_path = $file['tmp_name']; $uplod_path = __DIR__ . '/upload/'; if (! file_exists($uplod_path)) { mkdir($uplod_path); } $res = move_uploaded_file($file_tmp_path, $uplod_path . $file_name); var_dump($res); $response->end(111); }); $http->start(); ```
赞
0
回复
2020-06-08
凌霄一宇a
已经可以了,修改成base模式。是wsl的bug。
赞
0
回复
2021-08-02
nkligang
回复
凌霄一宇a
能具体一点说明怎么解决的么?
赞
0
回复