UASergey
(Linux Serg)
1
I have a lot of images. I should to valid them. But the images are on the local file system. How can I valid them without CUploadedFile::getInstance?
I tried to do this:
$_FILES['temp_path']['tmp_name'] = '/home/user/1.jpg';
$_FILES['temp_path']['name'] = '1.jpg';
$_FILES['temp_path']['type'] = 'image/jpeg';
$_FILES['temp_path']['size'] = '545458';
$_FILES['temp_path']['error'] = 0;
$model->attribute = CUploadedFile::getInstance($model, "temp_path");
But I have got an error Missing argument 2 for CActiveRecord::setAttribute().
Ankit_Modi
(Ankit Modi)
2
Hi just add on model rule function and set scenario like
array('image_name','required','on'=>'create'),
array('image_name', 'file', 'types' => 'jpg, jpeg, gif, png','on'=>'create','minSize'=>559631,'tooLarge'=>'The file was larger than 559631K. Please upload a smaller file.'),
array('image_name', 'file', 'allowEmpty' => TRUE,'types' => 'jpg, jpeg, gif, png','on'=>'update'),
I hope it’s some help
UASergey
(Linux Serg)
3
Unfortunately it does not work. 2nd rule in example requires ‘Temp Path cannot be blank.’
konapaz
(Konapaz)
4
attribute invoke setAttribute function that has 2 arguments (name and value)
http://www.yiiframework.com/doc/api/1.1/CActiveRecord#setAttribute-detail
are you seek attributes instead attribute ?
Also CUploadedFile::getInstance returns a CUploadedFile object, so you can’t pass masive attributes directly
What exactly are you trying to do?