Gc\Media\File::getPath PHP Method

getPath() public method

Return path
public getPath ( ) : string
return string
    public function getPath()
    {
        return realpath(GC_MEDIA_PATH . '/..');
    }

Usage Example

Example #1
0
 /**
  * Save upload editor
  *
  * @return void
  */
 public function save()
 {
     $fileClass = new File();
     $fileClass->load($this->getProperty(), $this->getDatatype()->getDocument());
     $post = $this->getRequest()->getPost();
     $values = $post->get($this->getName(), array());
     $parameters = $this->getConfig();
     $arrayValues = array();
     if (!empty($values) and is_array($values)) {
         foreach ($values as $idx => $value) {
             if (empty($value['name'])) {
                 continue;
             }
             $file = $fileClass->getPath() . '/' . $value['name'];
             if (file_exists($file)) {
                 $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
                 $finfo = finfo_open($const);
                 // return mimetype extension
                 if (!in_array(finfo_file($finfo, $file), $parameters['mime_list'])) {
                     unlink($file);
                 } else {
                     $fileInfo = @getimagesize($file);
                     $arrayValues[] = array('value' => $value['name'], 'width' => empty($fileInfo[0]) ? 0 : $fileInfo[0], 'height' => empty($fileInfo[1]) ? 0 : $fileInfo[1], 'html' => empty($fileInfo[2]) ? '' : $fileInfo[2], 'mime' => empty($fileInfo['mime']) ? '' : $fileInfo['mime']);
                 }
                 finfo_close($finfo);
             }
         }
         $returnValues = serialize($arrayValues);
     }
     $this->setValue(empty($returnValues) ? null : $returnValues);
 }
All Usage Examples Of Gc\Media\File::getPath