модель parsers.php
use common\models\UploadImage;
use yii\web\UploadedFile;
use dosamigos\transliterator\TransliteratorHelper;
$image=new Image();
$imageUrl=$informayion['poster_url'];
$images = file_get_contents(http://trinixy.ru/pics5/20121108/awesome_40.jpg);
$files= new UploadImage();
$files->files = UploadedFile::getInstance($files,$images);
$files_to = TransliteratorHelper::process($files->files->name, '', 'en');
$path = 'serial';
$image->id_serial=$theIdsSerial;
$years=date('Y');
$mounts=date('m');
if ($files->upload($path,$years,$mounts,$files_to)) {
$image->path = $path.'/'.$years.'/'.$mounts.'/';
$image->name = $files_to;
$image->save();
}else{
print_r($files->getErrors());
}
модель UploadImage.php
<?php
namespace common\models;
use Yii;
use yii\base\Model;
use yii\web\UploadedFile;
class UploadImage extends Model
{
public $files;
public function rules()
{
return [
[['files'], 'file','skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'],
];
}
public function upload($path,$years,$mounts,$files_to){
if ($this->validate()) {
if (file_exists(Yii::getAlias('@frontend/web/image/').$path.'/'.$years.'/'.$mounts.'/')) {
} else {
mkdir(Yii::getAlias('@frontend/web/image/').$path.'/'.$years.'/'.$mounts.'/', 0775, true);
}
$this->files->saveAs(Yii::getAlias('@frontend/web/image/').$path.'/'.$years.'/'.$mounts.'/'.$files_to);
return true;
} else {
return false;
}
}
}
по итогу говорит Call to a member function saveAs() on a non-object предполагаю что вот она ошибка
$images = file_get_contents(http://trinixy.ru/pics5/20121108/awesome_40.jpg);
$files->files = UploadedFile::getInstance($files,$images);
подскажите все же как правильно.