/** * Constructor * * @param UploadedFileBase $uploadedFile * @param CKFinder $app * * @throws \Exception if file upload failed */ public function __construct(UploadedFileBase $uploadedFile, CKFinder $app) { parent::__construct($uploadedFile->getClientOriginalName(), $app); $this->uploadedFile = $uploadedFile; $this->workingFolder = $app['working_folder']; $this->tempFilePath = tempnam($this->config->get('tempDirectory'), 'ckf'); $pathinfo = pathinfo($this->tempFilePath); if (!is_writable($this->tempFilePath)) { throw new InvalidUploadException('The temporary folder is not writable for CKFinder'); } try { $uploadedFile->move($pathinfo['dirname'], $pathinfo['basename']); } catch (\Exception $e) { $errorMessage = $uploadedFile->getErrorMessage(); switch ($uploadedFile->getError()) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: throw new InvalidUploadException($errorMessage, Error::UPLOADED_TOO_BIG, array(), $e); case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_NO_FILE: throw new InvalidUploadException($errorMessage, Error::UPLOADED_CORRUPT, array(), $e); case UPLOAD_ERR_NO_TMP_DIR: throw new InvalidUploadException($errorMessage, Error::UPLOADED_NO_TMP_DIR, array(), $e); case UPLOAD_ERR_CANT_WRITE: case UPLOAD_ERR_EXTENSION: throw new AccessDeniedException($errorMessage, array(), $e); } } }
/** * Constructor. * * @param string $fileName * @param string $folder * @param ResourceType $resourceType * @param CKFinder $app */ public function __construct($fileName, $folder, ResourceType $resourceType, CKFinder $app) { $this->folder = $folder; $this->resourceType = $resourceType; parent::__construct($fileName, $app); }