I'm completely confused on this. I'm trying to upload an image but I keep getting this error, I've searched the site and I've found tons of the same question but I couldn't get any of those solutions to work for me.
I have this code in my model that is supposed to convert the image array to a string.
public function processImageUpload($check = array()) {
if (!is_uploaded_file($check['image']['tmp_name'])){
return FALSE;
}
if (!move_uploaded_file($check['image']['tmp_name'], WWW_ROOT .
'img' . DS . 'uploads' . DS . $check['image']['name'])){
return FALSE;
}
$this->data[$this->alias]['image'] = 'uploads' . DS .
$check['image']['name'];
return TRUE;
}
Next up I have my add function from PostsController
public function add() {
if($this->request->is('post')) {
$this->request->data['Post']['username']= $this->Auth->user('username');
$this->Post->create();
$data = $this->request->data['Post'];
if (!$data['image']['name']){
unset($data['image']);
}
if($this->Post->save($data)) {
$this->Session->setFlash(__('Your post has been saved.'));
return $this->redirect(array('action'=>'index'));
}
$this->Session->setFlash(__('Unable to add your post.'));
}
}
Then I have my form where the file is uploaded.
echo $this->Form->create('Post', array('type' => 'file'));
echo $this->Form->input('title');
echo $this->Form->input('movie');
echo $this->Form->input('category');
echo $this->Form->input('description' , array('rows'=>'2'));
echo $this->Form->input('image', array('type' => 'file'));
echo $this->Form->end('Submit Article for Review');
So why is the function in my model not converting the array into a string? What am I not understanding here?