php - how to do multiple file upload in zend framework -
i implement multiple file upload. getting code single file uploading. how implement multiple file upload
form code
$docupload=new zend_form_element_file('docupload',array('multiple' => 'multiple')); $docupload->addvalidator(new zend_validate_file_extension('doc,docx,pdf,txt')); $docupload->setisarray(true);
in controller
if(is_array($_files['docupload']['name'])) { $params = $this->_form->getvalues(); foreach($_files['docupload']['name'] $key=>$files) { $file_name=$_files['docupload']['name'][$key]; $temp_image_path = $_files['docupload']['tmp_name'][$key]; $file_name=implode(",", $file_name); $temp_image_path=implode(",", $temp_image_path); ['tmp_name']; $path_parts = pathinfo($temp_image_path); $tem_path = $path_parts['dirname']; $path_parts_extension = pathinfo($file_name); $actual_filename=$path_parts_extension['filename']; $file_extension = $path_parts_extension['extension']; if(application_env != "development") { $path = '/'; } else { $path = '\\'; } $filename = $tem_path.$path.$file_name; $rename_uploadfile = $actual_filename.$random_number.".".$file_extension; $fullfilepath = upload_user_images.$rename_uploadfile; // rename uploaded file using zend framework $filterfilerename = new zend_filter_file_rename(array('target' => $fullfilepath)); $filterfilerename->filter($filename); $form_data=$params; $form_data['docupload']=$rename_uploadfile; if($id) { $this->_table->updatebyid("id",$id, $form_data); } else { $this->_table->insert($form_data); }
i new zend framework. please me.thanks in advance
rather use $_files variable, better use applicable zend code, considering you're using zend framework:
if (!$form->isvalid()) { print "uh oh... validation error"; } if (!$form->docupload->receive()) { print "error receiving file(s)"; } $files = $form->docupload->getfilename(); // result should array in case
Comments
Post a Comment