Bonjour j ss entraint de cree l'action edit de user ms mon prb est que ya prb de recupreration de image upload the user voici l'action edit :
public function edit($id = null) {
if (!$id) {
$this->Session->setFlash('Please provide a user id');
$this->redirect(array('action'=>'index'));
}
$user = $this->User->findById($id);
if (!$user) {
$this->Session->setFlash('Invalid User ID Provided');
$this->redirect(array('action'=>'index'));
}
if ($this->request->is('post') || $this->request->is('put')) {
$this->User->id = $id;
if ($this->request->data) {
debug('image :'.$this->request->data['User']['Photo_file']['name']);
$extension = strtolower(pathinfo($this->request->data['User']['Photo_file']['name'],PATHINFO_EXTENSION));
debug('extension'.$extension);
/*//debug($this->request->data['User']['Photo_file']['tmp_name']);
if (!empty($this->request->data['User']['Photo_file']['tmp_name']) && in_array($extension,array('jpg','png','jpeg'))) {
move_uploaded_file($this->request->data['User']['Photo_file']['tmp_name'],
IMAGES . 'avatars' .DS . $this->User->id .'.'.$extension);
$this->User->saveField('avatar',$extension);
debug($this->User->saveField('avatar',$extension));
$this->Session->setFlash(__('The user has been updated'));
$this->redirect(array('action' => 'index'));
}else if (!empty($this->request->data['User']['Photo_file']['tmp_name'])) {
$this->Session->setFlash(__('Type de fichier innaccepter'));
debug($this->User->saveField('avatar',$extension));
}*/
}else{
$this->Session->setFlash(__('Unable to update your user.'));
}
}
if (!$this->request->data) {
$this->request->data = $user;
}
}
la ligne
debug('image :'.$this->request->data['User']['Photo_file']['name']);
$extension = strtolower(pathinfo($this->request->data['User']['Photo_file']['name'],PATHINFO_EXTENSION));
debug('extension'.$extension);
donne comme resultat :
app\Controller\UsersController.php (line 117)
'image :i'
\app\Controller\UsersController.php (line 120)
'extension'