PHP Notice: Undefined offset: 1 in libs/Swoole/Http/Parser.php on line 141

该函数应改为 static function parseFormData($request, $cd) { $cd = '--' . str_replace('boundary=', '', $cd); $form = explode($cd, rtrim($request->body, "-")); //去掉末尾的-- foreach ($form as $f) { if ($f === '') continue; $parts = explode("\r\n\r\n", trim($f)); $head = self::parseHeaderLine($parts[0]); if (!isset($head['Content-Disposition'])) continue; $meta = self::parseParams($head['Content-Disposition']); //filename字段表示它是一个文件 if (!isset($meta['filename'])) { if(count($parts) < 2) $parts[1] = ""; //支持checkbox if (substr($meta['name'], -2) === '[]') $request->post[substr($meta['name'], 0, -2)][] = trim($parts[1]); else $request->post[$meta['name']] = trim($parts[1], "\r\n"); } else { * if( isset( $parts ) && isset( $parts[1] ) ){* $file = trim($parts[1]); $tmp_file = tempnam('/tmp', 'sw'); file_put_contents($tmp_file, $file); if (!isset($meta['name'])) $meta['name'] = 'file'; $request->file[$meta['name']] = array('name' => $meta['filename'], 'type' => $head['Content-Type'], 'size' => strlen($file), 'error' => UPLOAD_ERR_OK, 'tmp_name' => $tmp_file); } } } } 斜体部分为添加的代码。

2016-01-04 06:22
0
0

yydick - 80前IT男

赞同来自:

斜体部分被*号包围了

2016-01-04 06:23

要回复问题请先登录注册