Hello Tout le monde!!
Voila je travail sur l'upload de fichier sous Zend. Pour l'instant ça fonctionne car je récupère mon fichier et j'arrive à le transférer vers le dossier sur le serveur. Mais après cette action j'ai cette erreur:
Voici mon formulaire:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 An error occurred Application error Exception information: Message: File '../../parctel/fichier\conception_BDD' could not be renamed. An error occured while processing the file. Stack trace: #0 E:\Intranet\parctel\application\controllers\BfController.php(119): Zend_Filter_File_Rename->filter('../../parctel/f...') #1 E:\Intranet\parctel\library\Zend\Controller\Action.php(513): BfController->uploadAction() #2 E:\Intranet\parctel\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('uploadAction') #3 E:\Intranet\parctel\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #4 E:\Intranet\parctel\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch() #5 E:\Intranet\parctel\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #6 E:\Intranet\parctel\public\index.php(47): Zend_Application->run() #7 {main}
Ma vue:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
39
40
41
42
43
44
45
46
47
48
49
50 class Application_Form_Upload extends Zend_Form { public function init() { // La méthode HTTP d'envoi du formulaire $this->setMethod('post'); // Un élément file $file = $this->addElement('file', 'fichier', array( 'label' => 'fichier:', // 'multiple' => true, 'required' => true )); // Un élément titre $this->addElement('text', 'titre', array( 'label' => 'titre:', 'required' => true, 'filters' => array('StringTrim') )); $options = array( '0' => 'Aucun profil', '1' => 'Profil 1', '2' => 'Profil 2' ); // Un élément select $this->addElement('select', 'profil', array( 'label' => 'profil:', 'multiOptions' => $options, 'required' => true ),$options); // Un bouton d'envoi $this->addElement('submit', 'submit', array( 'ignore' => true, 'label' => 'Envoyer', )); } }
Et enfin mon controller:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <div id="bf" style="text-align:center;"> <br /> <br /> <h1 class='cn_h1' style='margin: 0 10px 10px 10px; padding: 0;'>Upload de fichier</h1> <br /> <?php $this->form->setAction($this->url()); echo $this->form; ?> </div>
Quelqu'un pourrait il m'aider ? Car je sais pas du tout comment régler cette erreur.... Et je vous remercie d'avance!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public function uploadAction() { $request = $this->getRequest(); $form = new Application_Form_Upload(); if ($this->getRequest()->isPost()) { if ($form->isValid($request->getPost())) { $upload = new Zend_File_Transfer(); $uploadDestination = '../../parctel/fichier'; $upload ->setDestination($uploadDestination); try { $upload->receive(); // Zend_Debug::dump($upload->getFileInfo()); } catch (Zend_File_Transfer_Exception $e) { throw new Exception($e->getMessage()); } $valeurs = $form->getValues(); $files = $upload->getFileInfo(); $filename = $upload->getFileName('fichier'); $chemin = "./parctel/fichier".$filename; //chemin du fichier $filterFileRename = new Zend_Filter_File_Rename(array('target' => $chemin, 'overwrite' => false)); $filterFileRename->filter($filename); //move uploade file to } } $this->view->form = $form; }![]()
Partager