예제 #1
0
	public function upload () {
		$image = new TempImage();
		
		if (array_key_exists("userfile", $_FILES) && file_exists($_FILES["userfile"]["tmp_name"])) {
			$file = $_FILES['userfile']['tmp_name'];
			$filename = $_FILES['userfile']['name'];
		
    		$image->replace($file);
    		$image->setOriginalFilename(basename($filename));
		} elseif (array_key_exists("url", $_REQUEST)) {
    		$image->replaceFromURL($_REQUEST["url"]);
    	} else {
    		throw new \Exception("Error: No valid file given");
    	}
    	
    	PartKeepr::getEM()->persist($image);
    	PartKeepr::getEM()->flush();
    	
    	return array("id" => $image->getId(), "extension" => $image->getExtension(), "size" => $image->getSize(), "originalFilename" => $image->getOriginalFilename());
	}
예제 #2
0
	/**
	 * (non-PHPdoc)
	 * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::create()
	 */
	public function create () {
		$this->requireParameter("tmp_id");
		$this->requireParameter("manufacturer_id");
		
		$tmpImage = TempImage::loadById($this->getParameter("tmp_id"));
		
		$image = new ManufacturerICLogo();
		
		$manufacturer = Manufacturer::loadById($this->getParameter("manufacturer_id"));
		
		$image->setManufacturer($manufacturer);
		$image->replace($tmpImage->getFilename());
		$image->setOriginalFilename($tmpImage->getOriginalFilename());
		PartKeepr::getEM()->persist($image);
		PartKeepr::getEM()->flush();
		
		return $image->serialize();
	}
예제 #3
0
파일: image.php 프로젝트: nessi/PartKeepr
			$image = PartImage::loadById($id);
			break;
		default:
			$image = null;
			// Add default image?
	}
	
} catch (\Exception $e) {
	$image = null;
	// Something bad happened
}

if ($image == null) {
	// Could not find the image, but maybe we want a temporary image?
	if (array_key_exists("tmpId", $_REQUEST)) {
		$image = TempImage::loadById($_REQUEST["tmpId"]);
	}
	
	if ($image === null) {
		/* The image is still null - output an "image not found" image.	 */
		$image = imagecreate($_REQUEST["w"], $_REQUEST["h"]);
		$white = imagecolorallocate($image, 255,255,255);
		$black = imagecolorallocate($image, 0,0,0);
		
		header("Content-Type: image/png");
		
		$w = $_REQUEST["w"]-1;
		$h = $_REQUEST["h"]-1;
		imagefill($image, 0,0, $white);
		
		/* Draw the X */