Detailed Description

FileUtil provides basic support for file functionality like HTTP file upload.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 22 of file FileUtil.php.

Static Public Member Functions

static uploadFile ($mediaFile, $destName, $mimeTypes=null, $override=true)
 
static fputsUnicode ($fp, $str)
 
static getFiles ($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false)
 
static getDirectories ($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false)
 
static copyRec ($source, $dest)
 
static copyRecDir ($source, $dest)
 
static mkdirRec ($dirname)
 
static emptyDir ($dirname)
 
static realpath ($path)
 
static sanitizeFilename ($file)
 

Member Function Documentation

static uploadFile (   $mediaFile,
  $destName,
  $mimeTypes = null,
  $override = true 
)
static

Copy an uploaded file to a given destination (only if the mime type mathes the given one).

Parameters
$mediaFileAn assoziative array with the following keys: 'name', 'type', 'tmp_name' (typically a $_FILES entry)
$destNameThe destination file name
$mimeTypesAn array holding the allowed mimetypes, null if arbitrary (default: null)
$overrideBoolean whether an existing file should be overridden, if false an unque id will be placed in the filename to prevent overriding (default: true)
Returns
The filename of the uploaded file

Definition at line 32 of file FileUtil.php.

static fputsUnicode (   $fp,
  $str 
)
static

Write unicode to file.

Parameters
$fpFile Handle
$strString to write

Definition at line 68 of file FileUtil.php.

static getFiles (   $directory,
  $pattern = '/./',
  $prependDirectoryName = false,
  $recursive = false 
)
static

Definition at line 80 of file FileUtil.php.

static getDirectories (   $directory,
  $pattern = '/./',
  $prependDirectoryName = false,
  $recursive = false 
)
static

Definition at line 120 of file FileUtil.php.

static copyRec (   $source,
  $dest 
)
static

Recursive copy for files/directories.

Parameters
$sourceThe name of the source directory/file
$destThe name of the destination directory/file

Definition at line 161 of file FileUtil.php.

static copyRecDir (   $source,
  $dest 
)
static

Recursive copy for directories.

Parameters
$sourceThe name of the source directory
$destThe name of the destination directory

Definition at line 178 of file FileUtil.php.

static mkdirRec (   $dirname)
static

Recursive directory creation.

Parameters
$dirnameThe name of the directory

Definition at line 196 of file FileUtil.php.

static emptyDir (   $dirname)
static

Empty a directory.

Parameters
$dirnameThe name of the directory

Definition at line 206 of file FileUtil.php.

static realpath (   $path)
static

Realpath function that also works for non existing paths code from http://www.php.net/manual/en/function.realpath.php.

Parameters
$path
Returns
String

Definition at line 225 of file FileUtil.php.

static sanitizeFilename (   $file)
static

Get a sanitized filename code from: http://stackoverflow.com/questions/2021624/string-sanitizer-for-filename#2021729.

Parameters
$file
Returns
String

Definition at line 256 of file FileUtil.php.