Bonjour,
j'essaye de faire un petit exemple pour uploader un fichier quelconque, mais j'y arrive pas et ça m'affiche des trucs que je pige pas !!
voici Mon code :
/models/FormulaireUpload :
/controller/autreContrller.php
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 <?php class FormulaireUpload extends Zend_Form { public function __construct($options = null) { parent::__construct($options); $this->setName('upload'); $this->setMethod('post'); $uploadPath= realpath("C:\wamp\www\ImageRandom\public\upload"); $upfile = new Zend_Form_Element_File('upfile'); $upfile->setLabel('Upload an image : ') ->setRequired(true) ->setDestination($uploadPath ); $this->addElement($upfile); $submit = new Zend_Form_Element_Submit('submit'); $this->addElement($submit); } }
views/autre/upload.phtml
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 function uploadAction(){ $this->view->title = "Upload de fichiers"; $form = new FormulaireUpload(); $form->submit->setLabel('Upload'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { echo "valide"; $ups=$form->getValues(); } else { echo "non valide"; $form->populate($formData); } Zend_Debug::dump($ups, '$ups'); exit; } }
le formulaire s'affiche correctement, mais quand je clique pour uploader, ça m'affiche ça :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <html> <head> <title><?php echo $this->escape($this->title); ?></title> </head> <body> <h1><?php echo $this->escape($this->title); ?></h1> <?php echo $this->form ;?> </body> </html>
Aussi sous le formulaire, un validateur que connais pas m'affiche : The file 'upfile' was illegal uploaded, possible attack
Notice: Undefined index: tmp_name in C:\wamp\www\ImageRandom\library\Zend\File\Transfer\Adapter\Abstract.php on line 589
Notice: Undefined index: error in C:\wamp\www\ImageRandom\library\Zend\Validate\File\Upload.php on line 168
Notice: Undefined index: tmp_name in C:\wamp\www\ImageRandom\library\Zend\Validate\File\Upload.php on line 170
non valide
Notice: Undefined variable: ups in C:\wamp\www\ImageRandom\application\controllers\AutreController.php on line 38
$ups NULL
PS: j'utilise la version 1.7 de ZEND
voilà, et merci d'avance
Bien cordialement
Partager