I\'m new in cakephp and i\'m trying to create a simple file upload with cakephp 2.3 here is my controller
public function add() {
if ($this->request-&
I've found the complete guide to uploading files and images in CakePHP from here - Handling File Uploads in CakePHP
The example code is given below.
Controller:
$fileName = $this->request->data['file']['name'];
$uploadPath = 'uploads/files/';
$uploadFile = $uploadPath.$fileName;
if(move_uploaded_file($this->request->data['file']['tmp_name'],$uploadFile)){
//DB query goes here
}
View:
Form->create($uploadData, ['type' => 'file']); ?>
Form->input('file', ['type' => 'file', 'class' => 'form-control']); ?>
Form->button(__('Upload File'), ['type'=>'submit', 'class' => 'form-controlbtn btn-default']); ?>
Form->end(); ?>