34k+
News
Guide
API
Wiki
Forum
Community
Places
Members
Hall of Fame
Badges
More
Learn
Books
Resources
Develop
Download Yii
Extensions
Report an Issue
Report a Security Issue
Contribute to Yii
Donate
About
Release Cycle
License
Team
Official Logos and Design
Login
How to read HTML5 Multiple File Input from controller?
Comparing
#3
with
#4
Revision #4 was created by
samdark
on Jan 20, 2019, 9:10:28 PM.
Set version
« Previous (#3)
Yii version
2.0
Tags
yii,
Yii,widget,input,multiple,HTML5,
yii2,
file,
input,
fileinput,
widget, upload, html5, multiple
upload
Content
[...]
Solution
--------
You must configure the attribute name for HTML5 file input in ARRAY FORMAT for PHP to recognize it as an array of files. So here is how you achieve this as shown below (note the square brackets in the attribute naming):
### For Yii 1.1
```php
echo $form->fileInput($model, 'uploadFile[]', ['multiple' => true]); ``` ### For Yii 2
```php
echo $form->field($model, 'uploadFile[]')->fileInput(['multiple' => true]); ``` ### For \kartik\widgets\FileInput (Yii 2)
```php
echo $form->field($model, 'uploadFile[]')->widget(FileInput::classname(), [ 'options'=>['multiple' => true] ]); ```