Как загрузить изображение на сервер sql и получить это изображение
Это метод, который я использовал для загрузки изображения на сервер SQL
public function add()
{
$category = $this->Categories->newEntity();
if ($this->request->is('post')) {
if(!empty($this->request->getData['image']['name'])){
$fileName = $this->request->getData['image']['name'];
$uploadPath = 'img/';
$uploadFile = $uploadPath.$fileName;
if($move_uploaded_file($this->request->getData['image']['tmp_name'],$uploadFile)){
$this->request->getData['image']=$fileName;
}
}
$category = $this->Categories->patchEntity($category, $this->request->getData());
if ($this->Categories->save($category)) {
//$this->Flash->success(__('The category has been saved.'));
return $this->redirect(['controller' => 'users','action' => 'index']);
}
// $this->Flash->error(__('The category could not be saved. Please, try again.'));
}
$this->set(compact('category'));
}
в add.ctp код
<?= $this->Form->create($category,array('type'=> 'file')); ?>
так что ошибка. Предоставленное значение является недопустимым.