PHP 클래스 yii\web\MultipartFormDataParser
This parser provides the fallback for the 'multipart/form-data' processing on non POST requests,
for example: the one with 'PUT' request method.
In order to enable this parser you should configure [[Request::parsers]] in the following way:
php
return [
'components' => [
'request' => [
'parsers' => [
'multipart/form-data' => 'yii\web\MultipartFormDataParser'
],
],
...
],
...
];
Method
MultipartFormDataParser::parse of this parser automatically populates
$_FILES with the files parsed from raw body.
> Note: since this is a request parser, it will initialize
$_FILES values on [[Request::getBodyParams()]].
Until this method is invoked,
$_FILES array will remain empty even if there are submitted files in the
request body. Make sure you have requested body params before any attempt to get uploaded file in case
you are using this parser.
Usage example:
php
use yii\web\UploadedFile;
$restRequestData = Yii::$app->request->getBodyParams();
$uploadedFile = UploadedFile::getInstancesByName('photo');
$model = new Item();
$model->populate($restRequestData);
copy($uploadedFile->tempName, '/path/to/file/storage/photo.jpg');
> Note: although this parser fully emulates regular structure of the
$_FILES, related temporary
files, which are available via
tmp_name key, will not be recognized by PHP as uploaded ones.
Thus functions like
is_uploaded_file() and
move_uploaded_file() will fail on them. This also
means [[UploadedFile::saveAs()]] will fail as well.
파일 보기
프로젝트 열기: yiisoft/yii2
공개 메소드들
비공개 메소드들
메소드 상세
getUploadFileMaxCount()
공개 메소드
getUploadFileMaxSize()
공개 메소드
public parse ( $rawBody, $contentType ) |
setUploadFileMaxCount()
공개 메소드
setUploadFileMaxSize()
공개 메소드