1

below code return "File '' is not readable or does not exist" always:

$filters = array(
    '*' => 'stringTrim'
);
$validators = array(
    'image'=> array(
        'allowEmpty' => TRUE,
        new Zend_Validate_File_ImageSize(array('minheight'=>0,'minwidth'=>0,'maxheight'=>1024,'maxwidth'=>1024)),
    )
);
$input = new Zend_Filter_Input($filters, $validators);
$input->setData(array_merge($data, $_FILES));
if (!$input->isValid()) {
    $this->_errors = $input->getMessages();
}

1 Answer 1

2

The input name of your file input has to be image. Also, be sure your form has enctype="multipart/form-data". The format of $_FILES is explained here.

Aside from that I don't detect any code in Zend_Validate_File_ImageSize that can operate on $_FILES. I think you've got to pass the actual path to the file, e.g. 'image' => $_FILES['image']['tmp_name'] (in your $input->setData() call).

Sign up to request clarification or add additional context in comments.

3 Comments

tnx, worked. $files['image'] = $_FILES['image']['tmp_name']; and use $files insteade $_FILES
now it return Maximum allowed width for image '' should be '94' but '128' detected. it should be Maximum allowed width for image 'image' should be '94' but '128' detected
Not sure about that one, might be a bug. If so, do report it to the ZF dev team.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.