Follow description below in your action's controller.
- Add
- Edit
- Delete
$this->request->data['Model']['fieldname'] = $this->FileHandler->fileAdd(
$this->request->data['Model']['fieldname']
);
This will save new uploaded file & if file had no errors return file name.
$fields = $this->Model->read(NULL, $id);
$this->request->data['Model']['field'] = $this->FileHandler->fileEdit(
$fields['Model'],
$id,
$this->request->data['Model']['field'],
$fieldname(optional)
);
This will unlink old file (if existed) & save new uploaded file & return new file name.
$fields = $this->Model->read(NULL, $id);
$this->FileHandler->fileDelete(
$fields['Model'],
$fieldname(optional)
);
This will unlink old file (if existed).