Exemple #1
0
 public static function getInstance($filePath)
 {
     $filePath = EFileHelper::realPath($filePath);
     if (!isset(self::$_files[$filePath])) {
         $file = self::$_files[$filePath] = new EFile($filePath);
         $file->_md = new EFileMetaData($file);
     }
     return self::$_files[$filePath];
 }
Exemple #2
0
 /**
  * @param string $fileName uploaded file
  * @param string $originalName original file name. Used for getting extension. If null - using $fileName.
  * @return string Uid of new file
  */
 public function publishFile($fileName, $originalName = null)
 {
     if (is_null($originalName)) {
         $originalName = $fileName;
     }
     $ext = strtolower(CFileHelper::getExtension($originalName));
     if (empty($ext)) {
         // we have empty extension. Trying determine using mime type
         $ext = EFileHelper::getExtensionByMimeType($fileName);
     }
     if (!empty($ext)) {
         $ext = '.' . $ext;
     }
     $uid = $this->getUniqId() . $ext;
     $publishedFileName = $this->getFilePath($uid);
     $newDirName = pathinfo($publishedFileName, PATHINFO_DIRNAME);
     if (!file_exists($newDirName)) {
         mkdir($newDirName, 0775, true);
     }
     copy($fileName, $publishedFileName);
     return $uid;
 }
Exemple #3
0
 /**
  * @return string
  */
 public function getSize()
 {
     return EFileHelper::fileSize($this->_filePath);
 }