Zend form and dynamic file upload
- by DoomStone
Hello there i'm trying to create a form with Zend_Form that will enable my user to upload a unlited number of files to my site, witch is done by javascript.
Something like
<script type="text/javascript">
$(document).ready(function(){
var image_uploade_i = 0;
$('#upload_more').click(function() {
image_uploade_i++;
$('#upload_list').append('<div id="image_uploade_id_'+image_uploade_i+'" style="display: none;"><input type="file" name="image[]" /><br /></a>');
$('#image_uploade_id_'+image_uploade_i).slideDown('slow');
});
});
</script>
<?=$this->translate('Add images')?>
<form action="" method="post" enctype="multipart/form-data">
<div id="upload_list">
<input type="file" name="image[]" /><br />
<input type="file" name="image[]" /><br />
<input type="file" name="image[]" /><br />
</div>
<a href="#" id="upload_more"><?=$this->translate('Upload another image')?></a><br />
<input type="submit" name="image_uploade" value="<?=$this->translate('Upload images')?>" />
</form>
But i'm am unable to find out how i can create something like this with Zend_From, the only reason i want to use Zend_Form on this thoug is for validation of the uploadet files.
$element = new Zend_Form_Element_File('image');
$element->setRequired(true)
->setLabel('Profile image')
->setDestination($store)
->setValueDisabled(true)
->addValidator(new Zend_Validate_File_ImageSize(array(
'minheight' => 100, 'minwidth' => 150,
'maxheight' => 1920, 'maxwidth' => 1200)))
// File must be below 1.5 Mb
->addValidator(new Zend_Validate_File_FilesSize(array('max' => 1572864)))
->addValidator(new Zend_Validate_File_IsImage());
If any 1 can help me set this up would i be verry great full :D