Reputation: 1253
I can't seem to figure out the cause of this error when trying to validate a image upload
$imagevalidate = Validate::factory($_FILES);
$imagevalidate->rules($_FILES['profile_picture'], array(
'Upload::valid' => array(),
'Upload::not_empty' => array(),
'Upload::type' => array(
'Upload::type' => array(
'jpg',
'png',
'gif'
)
),
'Upload::size' => array(
'1M'
)
));
if ($imagevalidate->check()) {
$picture = Upload::save($_FILES['profile_picture']);
Image::factory($picture)->resize(200, 200, Image::WIDTH)->save();
$profile->profile_picture = basename($picture);
} else {
$errors = $imagevalidate()->errors('profile/edit');
}
I am getting this error ErrorException [ Warning ]: Illegal offset type in isset or empty
Upvotes: 0
Views: 2476
Reputation: 241
in 3.2 example pass:
$array = Validation::factory($_FILES);
$array->rule('file', 'Upload::size', array(':value', '900KiB'));
$array->rule('file', 'Upload::type', array(':value', array('jpg', 'png', 'gif')));
$array->rule('file', 'Upload::image', array(':value', array(640, 480)));
$array->rule('file', 'Upload::valid');
if($array->check())
{
if(Upload::save($_FILES['file']))
echo 'uploaded';
}
else
{
echo Debug::vars($array->errors('profile/edit'));
}
messages file:
return array(
'file' => array(
'Upload::type' => 'blabla',
'Upload::size' => 'blabla',
'Upload::image' => 'blablan',
'Upload::valid' => 'blablabla'
),
);
un.. hope helpful:)
Upvotes: 2