Erreur Upload

Par bryou16, il y a 9 ans


Bonjour,

Voila je rencontre un petit problème avec mon code.

Ce que je fais

J'ai une erreur sur un Upload de fichier.

class Product extends AppModel{ public $belongsTo = 'Category'; public $validate = array( 'photo_file' => array( 'extension' => array( 'rule' => array('extension', array('jpeg', 'jpg', 'png')), 'message' => 'Erreur de format' ), 'poid' => array( 'rule' => array('fileSize', '<=', '8MB'), 'message' => 'L\'Image doit être inférieur à 8MB' ) ) ); public function afterSave($created, $options = array()){ if (isset($this->data[$this->alias]['photo_file'])) { $file = $this->data[$this->alias]['photo_file']; $extension = strtolower(pathinfo($file['tmp_name'], PATHINFO_EXTENSION)); debug($extension); if (!empty($file['tmp_name'])) { $oldextension = $this->field['photo']; $oldfile = IMAGES . 'produits' . DS . $this->id . '.' . $oldextension; if (file_exists($oldfile)) { unlink($oldfile); } move_uploaded_file($file['tmp_name'], IMAGES . 'produits' . DS . $this->id . '.' . $extension); $this->saveField('photo', $extension); } } } } public function add() { if ($this->request->is('post')) { $this->Product->create(); if ($this->Product->save($this->request->data,array('validate' => 'true'))) { return $this->redirect(array('action' => 'index')); } $this->Flash->error(__('Erreur.')); } }

Ce que j'obtiens

Warning (2): filesize(): stat failed for 2.png [CORE/Cake/Utility/Validation.php, line 965]
Warning (2): Illegal string offset 'tmp_name' [APP/Model/Product.php, line 26]

Je n'arrive pas à determiner l'erreur :(

Merci à vous

Aucune réponse