This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".  
Status: 2025-11-02

File


getMimeType

returns mimetype of a given file.

File::getMimeType(string $sFileAbsolute = '') : string

Example

$sMimeType = File::getMimeType(__FILE__);

Result

// type: string
'text/x-php'

info

get infos about a file via stat, posix_getpwuid, pathinfo.

File::info(string $sFilePathAbs = '') : DTFileinfo

Example

$oDTFileinfo = File::info(__FILE__);

return Datatype object $oDTFileinfo (see DTFileinfo)

 MVC\DataType\DTFileinfo {#91 ▼
  #dirname: "/var/www/html/modules/Foo/Controller"
  #basename: "Index.php"
  #path: "/var/www/html/modules/Foo/Controller/Index.php"
  #is_file: true
  #is_dir: false
  #extension: "php"
  #filename: "Index"
  #name: "admin1"
  #passwd: "x"
  #uid: 1000
  #gid: 1000
  #filemtime: 1739435042
  #filectime: 1739435042
  #filesize: 7562
  #gecos: ""
  #dir: "/home/admin1"
  #shell: "/bin/bash"
  #mimetype: "text/x-php"
}

Example: get Extension

$sExtension = File::info(__FILE__)->get_extension();

Result

php

saveIntoTemp

writes data into a -temporary- file; returns absolute path to that file.

File::saveIntoTemp(mixed $mData = null, string $sPrefix = '', string $sSuffix = '') : string

Example

$sFileAbs = File::saveIntoTemp(
    'some Foo Bar Data'
);

// "/tmp/temp.ff4kdvv5i07o0AaUnYi"
dump($sFileAbs);

secureFilePath

removes doubleDot+Slashes (../) from string, replaces multiple forwardSlashes (//) from string by a single forwardSlash.

File::secureFilePath(string $sAbsoluteFilePath = '', bool $bIgnoreProtocols = false) : string

Example

$sPath = File::secureFilePath('../../../../../../../../../../../var/www/htdocs/../../..////////Emvicy/modules/Foo/Controller/Index.php');

Result

// type: string
'var/www/htdocs/Emvicy/modules/Foo/Controller/Index.php'

temp

creates a -temporary- file; returns absolute path to that file.

File::temp(string $sPrefix = '', string $sSuffix = '') : string

Example

$sFileAbs = File::temp();

// "/tmp/temp.ff4kdvv5i07o0AaUnYi"
dump($sFileAbs);