/** * Delete image from file storage and database * * @param FileModelInterface $model File being deleted */ public function deleteFile(FileModelInterface $model) { $url = $model->getUploadDir() . DS . $model->getFile(); @unlink(str_replace('..', '', $url)); $model->delete(); }
protected function addFileToArray(FileModelInterface $model, array &$paths) { $path = $model->getUploadDir() . DS . $model->getFile(); if (is_file($path) && is_readable($path)) { $parent = $model->getParentFileModel(); $name = constant($parent::TABLE_MAP . "::TABLE_NAME"); $paths[$name . DS . $model->getFile()] = $path; } }