1
我使用Zend Element File上傳三個文件。我正在上傳並重命名這些文件。現在的問題是,上傳相同的分機時,它產生的Zend文件上傳重命名錯誤
Zend_Filter_Exception: File 'D:\wamp2\tmp\php2443.tmp' could not be renamed. It already exists.
錯誤例如,如果在第一個我上傳的文件在第二extenstiono .txt
的我上傳的文件.docx
,並在第三個我再次選擇.txt
或.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();
}
jambbbbbbbbooooooooooooo ....謝謝老兄 –