Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
N/A
-
Resolution: Incomplete
-
Affects Version/s: 1.9.2
-
Fix Version/s: 1.10.0
-
Component/s: Zend_File_Transfer
-
Labels:None
Description
It seems that the problem is with the fact that ajaxForm doesn't put anything in $_FILES if no file is specified,
it wasn't a problem with the post size,
sorry for wasting time.
can someone delete this issue since it doesn't really belong here.
-----------------------------------------------------------------
I created a Zend_Form_Element_File object, and set isRequired to false, but when I have no file uploaded, the form returns false when validating.
I debuged the validate operation and I can see that the that Zend_File_Transfer_Adapter_Http tries to set the ignoreNoFile option to every file
if (!$this->isRequired()) {
$adapter->setOptions(array('ignoreNoFile' => true), $this->getName());
}
.......
but when it validates it doesn't take in account this options and returns false
if($adapter->isValid($this->getName())) { $this->_validated = true; return true; }
the code above is from the zend library (that's where I think the problem is)
my code is below
the form file
$image = new Zend_Form_Element_File('imageUpload');
$image->setLabel('Upload an image:');
$image->setValueDisabled(true);
// 1 file
$image->addValidator('Count', false, 1);
// limit 100K
$sizeLimit = 102400;
// server limit
$image->addValidator('Size', false, $sizeLimit);
// client limit
$image->setMaxFileSize($sizeLimit);
// JPEG, PNG, GIFs
$image->addValidator('Extension', false, 'jpeg,jpg,png,gif');
.....
if($mode == 'update') {
....
$image->setRequired(false);
}
and processing the form:
$form = $this->_getCategoryForm('update');
if(array_key_exists('submitButton', $values)) {
// submit form, save changes
//$form->populate($values);
if ($form->isValid($values)) { <- here it returns false if I don't have a file uploaded. I debugged it, and the problem is with the file element
should I upload the entire php script ?
The second line you've mentioned sets the option on the adapter... it calls "setOptions"... no need to set a already stored option once again. Also, the adapter has no second option on the isValid method which could be given... I'm sorry to say that but your expectation is wrong.
When you have a problem, then you should give a example of your own code showing the problem, otherwise we can not see where your problem is.