public function getContents() { // future implementation can try to work around safe_mode and open_basedir limitations return $this->isOk() ? file_get_contents($this->tmpName) : NULL; }
/** * @param FileUpload|NULL $file * @param string $folder * * @return array|bool */ protected function saveImage(FileUpload $file = NULL, $folder = '') { if ($this->mainManager instanceof MagicManager) { $folder = $this->mainManager->getImageFolder(); } else { if ($folder == '') { $folder = 'misc'; } } // Main image $image = NULL; if (isset($file) && $file->isOk()) { // Save ... $year = date('Y'); $month = date('m'); $namespace = "{$folder}/{$year}/{$month}"; $this->imageStorage->setNamespace($namespace); $image = $this->imageStorage->save($file->getContents(), $file->getName()); $filename = pathinfo($image->getFile(), PATHINFO_BASENAME); // Prepare thumbnail $this->imgPipe->setNamespace($namespace); $this->imgPipe->request($filename, '200x200', 'exact'); $this->imgPipe->setNamespace($namespace); $this->imgPipe->request($filename, '100x100', 'exact'); $data = ['namespace' => $namespace, 'filename' => $filename]; return $data; } else { return FALSE; } }