skipOnEmpty is not working

  1. I am trying to upload image. I can upload image successfully when i write code as

[['file'], 'file']

.

But i have problem when i write code


[['file'], 'file', 'skipOnEmpty' => false],

.

Page refresh and file input gets blank.

  1. How do i give multiple file input?

ex smallimage, largeimage at different places

You do not see any error message but the system probably encounters a bad validation.

You can understand problemy by this


} else { print_r($model->getErrors())  ;}  exit;

2.Uploading multiple files

View:


<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>

<?= $form->field($model, 'file')->fileInput() ?>

<?php ActiveForm::end(); ?>



Little example controllers:


if ($model->file = UploadedFile::getInstance($model, 'file')) {

	

	$model->photo = $model->file->baseName  . $model->file->extension;

	

	if (1==1) { 

	$model->file->saveAs('path/to/'.$model->photo);

	

	} else { 

	$model->file->saveAs('path2/to/'.$model->photo);}