1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
public function ajouterAction()
{
// Admin
$form = new Application_Form_Artiste();
$form->envoyer->setLabel('Ajouter');
$this->view->form = $form;
if($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$nom = $form->getValue('nom');
$description = $form->getValue('description');
$artistes = new Application_Model_DbTable_Artistes();
$id = $artistes->ajouterArtiste($nom, $description);
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination(UPLOAD_PATH);
try {
$upload->receive();
} catch(Zend_File_Transfer_Exception $e) {
$e->getMessage();
}
$name = $upload->getFilename('photo');
$renameFile = "artiste-" . $id . "-photo.jpg";
Zend_Debug::dump($id);
$fullFilePath = MEDIA_PATH . '/images/' . $renameFile;
$filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
$filterFileRename->filter($name);
$this->_helper->redirector('gerer','artistes');
} else {
$form->populate($formData);
}
}
} |
Partager