Php 如何在zend framework中进行多文件上传
我想实现多文件上传。我得到这个代码只有一个文件正在上传。如何实现多文件上传 表格代码Php 如何在zend framework中进行多文件上传,php,zend-framework,file-upload,Php,Zend Framework,File Upload,我想实现多文件上传。我得到这个代码只有一个文件正在上传。如何实现多文件上传 表格代码 $docupload=new Zend_Form_Element_File('docupload',array('multiple' => 'multiple')); $docupload->addValidator(new Zend_Validate_File_Extension('doc,docx,pdf,txt')); $docu
$docupload=new Zend_Form_Element_File('docupload',array('multiple' => 'multiple'));
$docupload->addValidator(new Zend_Validate_File_Extension('doc,docx,pdf,txt'));
$docupload->setIsArray(true);
在控制器中
if(is_array($_FILES['docupload']['name']))
{
$params = $this->_form->getValues();
foreach($_FILES['docupload']['name'] as $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);
}
我是zend框架的新手。请帮助我。请提前感谢与其使用$\u FILES变量,不如使用适用的Zend代码,因为您正在使用Zend作为您的框架:
if (!$form->isValid()) {
print "Uh oh... validation error";
}
if (!$form->docupload->receive()) {
print "Error receiving the file(s)";
}
$files = $form->docupload->getFileName(); // result should be an array in this case
我加了那句话。但有时上传,有时不上传。有什么问题?