You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
517 B
29 lines
517 B
6 years ago
|
<?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]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
?>
|