示例#1
0
 public static function getImageInfo($path)
 {
     if (!is_file($path)) {
         return null;
     }
     $image_info = array();
     list($width, $height, $type, $attr) = getimagesize($path, $image_info);
     $info = FSService::getFileInfo($path);
     $info['width'] = $width;
     $info['height'] = $height;
     return $info;
 }
示例#2
0
 public function uploadAction()
 {
     $tmpLocation = DC::getEnvironment()->getTmpRoot() . session_id() . '/' . $this->_moduleName . '/';
     FSService::makeWritable($tmpLocation);
     $sessionStorage = new SessionStorage(array(), 'file_storage_' . $this->_moduleName);
     $preview = array();
     $files = FilesAbility::reformatFilesArray($_FILES);
     foreach ($files as $index => $fileList) {
         $filesToSave = array();
         $fieldName = false;
         foreach ($fileList as $name => $info) {
             $location = $tmpLocation . $name . '/';
             FSService::makeWritable($location);
             move_uploaded_file($info['tmp_name'], $location . $info['name']);
             $filesToSave[] = $location . $info['name'];
             $preview[$name] = FSService::getFileInfo($location . $info['name']);
             $preview[$name]['link'] = 'admin/' . $this->_moduleName . '/tmp-file/?p=' . $preview[$name]['link'];
             $fieldName = $name;
         }
         if ($fieldName) {
             $sessionStorage->set($fieldName, $filesToSave);
         }
     }
     $this->setData($preview, 'preview');
 }
示例#3
0
 public function getModelValue($storagePath, $aliasInfo)
 {
     $filesToInfo = GLOB($storagePath . '*', GLOB_MARK);
     $value = array();
     foreach ($filesToInfo as $file) {
         if (is_dir($file)) {
             continue;
         }
         $fileInfo = FSService::getFileInfo($file);
         if (!empty($aliasInfo['sizes'])) {
             foreach ($aliasInfo['sizes'] as $sizeAlias => $sizeInfo) {
                 $fileInfo[$sizeAlias] = FSService::getFileInfo($storagePath . $sizeAlias . '/' . $fileInfo['full_name']);
             }
         }
         $value[] = $fileInfo;
     }
     return empty($aliasInfo['multiple']) && count($value) ? $value[0] : $value;
 }