There is a project on Yii2, there is a form with a file upload, for uploading a file I use this extension yii2-dropzone
There are no errors in the logs, but for some reason the files are not loaded.
Here is the widget output:
\kato\DropZone::widget([ 'options' => [ 'maxFilesize' => '2', 'url' => '/site/upload', // upload url ], 'clientEvents' => [ 'complete' => "function(file){console.log(file)}", 'removedfile' => "function(file){alert(file.name + ' is removed')}" ], ]); and code in the controller
public function actionUpload(){ $fileName = 'upFile'; $uploadPath = '/var/www/ppms/web/site/upload'; if (isset($_FILES[$fileName])) { $file = \yii\web\UploadedFile::getInstanceByName($fileName); //Print file data print_r($file); if ($file->saveAs($uploadPath . '/' . $file->name)) { //Now save file data to database echo \yii\helpers\Json::encode($file); } } return false; }