public function uploadAction($parameter) {
        try {
            if(!$files = $this->request->files()) {
                return $this->jsonResult(400, 'Failed to upload file.', 'error_upload_failed');
            }

            foreach($files as $file) {
                if($error = $file->getError()) {
                    return $this->jsonResult(400, "Failed to upload file '%s'.", "error_upload_failed_detail", [$file->getError()]);
                }
            }

            $this->initFromSession();

            $this->deleteFile();

            $dir = $this->getUploadDir();

            if(!Misc::recursiveMkdir($dir, 0700)) {
                return $this->jsonResult(500, "Failed to create upload directory at '%s'.", "error_createdir_failed", [$dir]);
            }

            foreach($files as $file) {
                $target = "$dir/".$file->getName();

                if(!$file->moveTo($target)) {
                    return $this->jsonResult(500, 'Failed to move file.', 'error_move_failed');
                }
            }

            $this->file = $target;

            $this->filename = $file->getName();

            $this->filesize = $file->getSize();

            $this->saveToSession();

            $this->cleanFiles();

            return $this->jsonResult();
        }
        catch(Exception $e) {
            return $this->jsonResult(500, $e->getMessage());
        }
    }