我正在使用 Zend Element File 上传三个文件。我正在上传和重命名文件。现在的问题是,在上传相同的扩展程序时,它会产生错误
Zend_Filter_Exception: File 'D:\wamp2\tmp\php2443.tmp' could not be renamed. It already exists.
例如,如果在第一个文件中我.txt
在第二个文件中上传扩展文件,.docx
在第三个文件中我再次选择.txt
or .docx
,它将产生上述给定的错误。
但是如果我选择三个不同的扩展名,那么一切都会变得最好。我正在使用以下代码
if ($form->med_file_1->isUploaded()) {
$originalFilename = pathinfo($form->med_file_1->getFileName());
$newFilename = time() . '.' . $originalFilename['extension'];
$form->med_file_1->addFilter('Rename', "application_data/uploaded_files/patients/" . $newFilename,$originalFilename['basename']);
$form->med_file_1->receive();
}
if ($form->med_file_2->isUploaded()) {
$originalFilename = pathinfo($form->med_file_2->getFileName());
$newFilename = time() . '.' . $originalFilename['extension'];
$form->med_file_2->addFilter('Rename', "application_data/uploaded_files/patients/" . $newFilename,$originalFilename['basename']);
$form->med_file_2->receive();
}
if ($form->med_file_3->isUploaded()) {
$originalFilename = pathinfo($form->med_file_3->getFileName());
$newFilename = time() . '.' . $originalFilename['extension'];
$form->med_file_3->addFilter('Rename', "application_data/uploaded_files/patients/" . $newFilename,$originalFilename['basename']);
$form->med_file_3->receive();
}