예제 #1
0
 /**
  * Returns the MIME content type of an uploaded file.
  * @return string
  */
 public function getContentType()
 {
     if ($this->isOk() && $this->type === NULL) {
         $this->type = Nette\Utils\MimeTypeDetector::fromFile($this->tmpName);
     }
     return $this->type;
 }
예제 #2
0
 /**
  * Returns the MIME content type of file.
  *
  * @param  string
  *
  * @return string
  */
 public static function fromFile($file)
 {
     if ($mime = static::extensionToMime(pathinfo($file, PATHINFO_EXTENSION), FALSE)) {
         return $mime;
     }
     return Nette\Utils\MimeTypeDetector::fromFile($file);
 }
예제 #3
0
파일: Media.php 프로젝트: lucien144/Restful
 /**
  * Create media from file
  * @param string $filePath
  * @param string|NULL $mimeType
  * @return Media
  */
 public static function fromFile($filePath, $mimeType = NULL)
 {
     if (!$mimeType) {
         $mimeType = MimeTypeDetector::fromFile($filePath);
     }
     return new Media(file_get_contents($filePath), $mimeType);
 }
예제 #4
0
 /**
  * Replace image with data uri
  * @param type $url
  * @param type $quote
  * @param type $sourcePath 
  */
 public static function convert($url, $sourcePath)
 {
     $file = $sourcePath . DIRECTORY_SEPARATOR . $url;
     if (file_exists($file)) {
         $type = \Nette\Utils\MimeTypeDetector::fromFile($file);
         return 'data:' . ($type ? "{$type};" : '') . 'base64,' . base64_encode(file_get_contents($file));
     } else {
         return $url;
     }
 }
예제 #5
0
파일: CUrl.php 프로젝트: svobodni/web
 /**
  * Prepare file for send
  *
  * @param string $filename
  * @param string $mimetype
  * @param string $postname
  * @return \CURLFile|string
  */
 public function fileCreate($filename, $mimetype = NULL, $postname = NULL)
 {
     if (PHP_VERSION_ID < 50500) {
         return '@' . $filename;
     }
     if ($mimetype === NULL) {
         $mimetype = MimeTypeDetector::fromFile($filename);
     }
     if ($postname === NULL) {
         $postname = basename($filename);
     }
     return curl_file_create($filename, $mimetype, $postname);
 }
예제 #6
0
	/**
	 * @return string
	 */
	public function getMimeType()
	{
		return \Nette\Utils\MimeTypeDetector::fromFile($this->getStorageDir() . "/" . $this->path);
	}
예제 #7
0
trim(Nette\Utils\Strings::webalize($this->name,'.',FALSE),'.-');}function
getContentType(){if($this->isOk()&&$this->type===NULL){$this->type=Nette\Utils\MimeTypeDetector::fromFile($this->tmpName);}return$this->type;}function
예제 #8
0
 /**
  * Return's file content type
  *
  * @param string $filePath File path
  *
  * @return string
  */
 public function fileContentType($filePath)
 {
     return \Nette\Utils\MimeTypeDetector::fromFile($filePath);
 }