public function handleSaveImage()
	{
		if ($this->mainManager instanceof MagicManager
			&& $this->mainManager->isGallery()
		) {
			$folder = $this->mainManager->getGalleryFolder();
		} else {
			$this->error();
		}
		if ($folder == '') {
			$folder = 'misc';
		}

		$file = $this->httpRequest->getFile('Filedata');

		if ($file && $file->isOk() && $this->detailObject) {

			// 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);
			$size = $image->getSize();

			// Prepare thumbnail
			$this->imgPipe->setNamespace($namespace);
			$this->imgPipe->request($filename, '100x100', 'exact');

			// Save to database
			$this->mainManager->addGalleryImage($filename, $namespace, $size->getWidth(), $size->getHeight(),
				$file->getContentType(), $this->detailObject->id);

			$response = [
				'status' => '1',
				'height' => $size->getHeight(),
				'width' => $size->getWidth(),
				'mime' => $file->getContentType(),
			];

		} else {
			$response = [
				'status' => '0',
				'error' => 'Error while uploading file',
				'code' => 500,
			];
		}

		$this->sendJson($response);
	}
public function handleSaveImage()
	{
		if ($this->mainManager instanceof MagicManager
			&& $this->mainManager->isGallery()
		) {
			$folder = $this->mainManager->getGalleryFolder();
		} else {
			$this->error();
		}
		if ($folder == '') {
			$folder = 'misc';
		}

		$file = $this->httpRequest->getFile('Filedata');

		if ($file && $file->isOk() && $this->detailObject) {

			// 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);
			$size = $image->getSize();

			// Prepare thumbnail
			$this->imgPipe->setNamespace($namespace);
			$this->imgPipe->request($filename, '100x100', 'exact');

			// Save to database
			$this->mainManager->addGalleryImage($filename, $namespace, $size->getWidth(), $size->getHeight(),
				$file->getContentType(), $this->detailObject->id);

			$response = [
				'status' => '1',
				'height' => $size->getHeight(),
				'width' => $size->getWidth(),
				'mime' => $file->getContentType(),
			];

		} else {
			$response = [
				'status' => '0',
				'error' => 'Error while uploading file',
				'code' => 500,
			];
		}

		$this->sendJson($response);
	}
public function handleSaveImage ( ) { if ( $ this -> mainManager instanceof MagicManager && $ this -> mainManager -> isGallery ( ) ) { $ folder = $ this -> mainManager -> getGalleryFolder ( ) ; } else { $ this -> error ( ) ; } if ( $ folder == '' ) { $ folder = 'misc' ; } $ file = $ this -> httpRequest -> getFile ( 'Filedata' ) ; if ( $ file && $ file -> isOk ( ) && $ this -> detailObject ) { // 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 ) ; $ size = $ image -> getSize ( ) ; // Prepare thumbnail $ this -> imgPipe -> setNamespace ( $ namespace ) ; $ this -> imgPipe -> request ( $ filename , '100x100' , 'exact' ) ; // Save to database $ this -> mainManager -> addGalleryImage ( $ filename , $ namespace , $ size -> getWidth ( ) , $ size -> getHeight ( ) , $ file -> getContentType ( ) , $ this -> detailObject -> id ) ; $ response = [ 'status' => '1' , 'height' => $ size -> getHeight ( ) , 'width' => $ size -> getWidth ( ) , 'mime' => $ file -> getContentType ( ) , ] ; } else { $ response = [ 'status' => '0' , 'error' => 'Error while uploading file' , 'code' => 500 , ] ; } $ this -> sendJson ( $ response ) ; }
it's not only handleGallerySaveImage now. We use it for save texy images too
it s not only handleGallerySaveImage now . We use it for save texy images too