我有一個包含其中的代碼是這樣的圖像如何命名Zend框架中上傳的文件
$image->setDestination(APPLICATION_PATH . '/../public/images/upload');
,並在我的控制器我有一個表格和表格
if($countryForm->image->isUploaded())
{
$countryForm->image->receive();
$countryModel->addCountry(
$countryForm->getValue('name'),
$countryForm->getValue('description'),
$this->view->baseUrl('/images/upload/'.basename($countryForm->image->getFileName()))
);
}
怎麼能我更改上傳的文件名稱。我想將它設置爲
random(100).time().ext
嘗試這種代碼
if($form->image->isUploaded()){
$upload = new Zend_File_Transfer();
$upload->addFilter('Rename', array('target' => APPLICATION_PATH.'/../images/upload/'.time().'.jpg', 'overwrite' => true));
$form->image->receive();
$filename = $form->image->getFilename();
$pageModel->addPage($form->getValue('pagetitle'),
$form->getValue('pagemetakeyword'),
$form->getValue('pagemetadescription'),
$form->getValue('pagecategory'),
$filename,
$form->getValue('pagecontent'),
$form->getValue('pagestatus')
);
}
仍然給予「後端/公/圖像/上傳/ picture.jpg」在我的數據庫
我有我形成下面的代碼
$image = $this->createElement('file', 'image');
$image->setLabel('Image: ');
$image->setRequired(FALSE);
$image->setDestination(APPLICATION_PATH . '/../public/images/upload/');
$image->addValidator('Count', false, 1);
$image->addValidator('Size', false, 1024000);
$image->addValidator('Extension', false, 'jpg,jpeg,png,gif');
$this->addElement($image);
,我使用Ubuntu
哪裏做?在形式?? – 2010-12-05 10:17:02
isUploaded()if,before receive() – Ashley 2010-12-05 10:34:12