Parses HTTP bodies encoded as multipart/form-data
.
You can install this package via Composer:
composer kekos/multipart-form-data-parser
<?php
use Kekos\MultipartFormDataParser\Parser;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
/** @var ServerRequestInterface $request */
/** @var UploadedFileFactoryInterface $uploaded_file_factory */
/** @var StreamFactoryInterface $stream_factory */
$parser = Parser::createFromRequest($request, $uploaded_file_factory, $stream_factory);
$parser->decorateRequest($request);
$post_fields = $request->getParsedBody();
$files = $request->getUploadedFiles();
Report bugs in GitHub issues or feel free to make a pull request :-)
MIT