Beispiel #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;
 }
 /**
  * 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);
 }
Beispiel #3
0
 /**
  * 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);
 }
Beispiel #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;
     }
 }
Beispiel #5
0
 /**
  * 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);
 }
Beispiel #6
0
	/**
	 * @return string
	 */
	public function getMimeType()
	{
		return \Nette\Utils\MimeTypeDetector::fromFile($this->getStorageDir() . "/" . $this->path);
	}
Beispiel #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
Beispiel #8
0
 /**
  * Return's file content type
  *
  * @param string $filePath File path
  *
  * @return string
  */
 public function fileContentType($filePath)
 {
     return \Nette\Utils\MimeTypeDetector::fromFile($filePath);
 }