public function uploadAction()
{
$property = Property\Model::fromId($this->getRouteMatch()->getParam('property_id'));
$document = Document\Model::fromId($this->getRouteMatch()->getParam('document_id'));
if (!$this->getRequest()->isPost() or empty($document) or empty($property)) {
return $this->returnJson(array('error' => true));
}
$fileClass = new File();
$fileClass->load($property, $document);
$files = array();
if ($fileClass->upload()) {
$files = $fileClass->getFiles();
}
if (!empty($files)) {
return $this->returnJson(array('files' => $files));
}
return $this->returnJson(array('error' => true));
}