After failing in uploading a CSV using a model, I just copy and paste the model, view and controller that appears on the documentation (http://www.yiiframework.com/doc-2.0/guide-input-file-upload.html) and after checking that worked correctly I just edit it to accept other file formats.
What is weird is that in both cases the file is being uploaded correctly, but the "Validate()" method is failing for the CSV file.
Here you can see both the Object uploaded before and after the validation.
The validation result is 1 for the picture and empty for the CSV.
First for a picture :
app\models\UploadForm Object
(
[imageFile] => yii\web\UploadedFile Object
(
[name] => CAJITA.jpg
[tempName] => /tmp/phpz2ER1z
[type] => image/jpeg
[size] => 161126
[error] => 0
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] =>
)
yii\web\UploadedFile Object
(
[name] => CAJITA.jpg
[tempName] => /tmp/phpz2ER1z
[type] => image/jpeg
[size] => 161126
[error] => 0
)
For a CSV file:
app\models\UploadForm Object
(
[imageFile] => yii\web\UploadedFile Object
(
[name] => Comercial y Marketing_TRIMMED.csv
[tempName] => /tmp/phpei4csl
[type] => text/csv
[size] => 2913
[error] => 0
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] =>
)
yii\web\UploadedFile Object
(
[name] => Comercial y Marketing_TRIMMED.csv
[tempName] => /tmp/phpei4csl
[type] => text/csv
[size] => 2913
[error] => 0
)
Anyone with this issue ?