пытаюсь на базе yii 2 basic загрузить изображение.
пошел по пути инструкции
https://github.com/yiisoft/yii2/blob/master/docs/g...
localhost\gameproj\models\UploadForm.php
<?php
namespace app\models;
use yii\base\Model;
use yii\web\UploadedFile;
/**
* UploadForm is the model behind the upload form.
*/
class UploadForm extends Model
{
/**
* @var UploadedFile file attribute
*/
public $file;
/**
* @return array the validation rules.
*/
public function rules()
{
return [
[['file'], 'file'],
];
}
}
localhost\gameproj\views\upload\index.php
<?php
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($model, 'file')->fileInput() ?>
<button>Отправить</button>
<?php ActiveForm::end() ?>
localhost\gameproj\controllers\UploadController.php
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\UploadForm;
use yii\web\UploadedFile;
class SiteController extends Controller
{
public function actionUpload()
{
$model = new UploadForm();
if (Yii::$app->request->isPost) {
$model->file = UploadedFile::getInstance($model, 'file');
if ($model->file && $model->validate()) {
$model->file->saveAs('uploads/' . $model->file->baseName . '.' . $model->file->extension);
}
}
return $this->render('upload', ['model' => $model]);
}
}
gameproj/upload
получаю
Unknown Class – yii\base\UnknownClassException
Unable to find 'app\controllers\UploadController' in file: D:\open\OpenServer\domains\localhost\gameproj/controllers/UploadController.php. Namespace missing?