47 lines
712 B
PHP
47 lines
712 B
PHP
<?php
|
|
namespace backend\models;
|
|
|
|
use yii\base\Model;
|
|
use common\models\User;
|
|
use common\models\Image;
|
|
|
|
class UploadForm extends Model{
|
|
|
|
|
|
const SECRET= "aN6obLS2wMFzXw2VQBar";
|
|
|
|
public $image ;
|
|
public $secret;
|
|
|
|
/**
|
|
* @inheritdoc
|
|
* @formatter:off
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
|
|
[['image'], 'image', 'mimeTypes' => 'image/jpeg, image/png', 'extensions'=>'jpg, png'],
|
|
[['image'], 'required',],
|
|
[['secret'], 'required'],
|
|
[['secret'], 'validSecret'],
|
|
|
|
];
|
|
}
|
|
|
|
public function validSecret(){
|
|
if ( $this->secret != self::SECRET ){
|
|
$this->addError("secret","Invalid secret");
|
|
}
|
|
}
|
|
|
|
|
|
public function save(){
|
|
|
|
$image = new Image();
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
} |