FileUtil.php
26 * @param $mediaFile An associative array with the following keys: 'name', 'type', 'tmp_name' (typically a $_FILES entry)
29 * @param $override Boolean whether an existing file should be overridden, if false an unique id will be placed in the filename to prevent overriding (default: _true_)
43 throw new IOException($message->getText("File '%0%' has wrong mime type: %1%. Allowed types: %2%.",
56 throw new IOException($message->getText("Failed to move %0% to %1%.", [$mediaFile['tmp_name'], $destName]));
94 * @param $prependDirectoryName Boolean whether to prepend the directory name to each file (default: _false_)
98 public static function getFiles($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false) {
104 throw new IllegalArgumentException($message->getText("The directory '%0%' does not exist.", [$directory]));
134 * @param $prependDirectoryName Boolean whether to prepend the directory name to each directory (default: _false_)
138 public static function getDirectories($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false) {
144 throw new IllegalArgumentException($message->getText("The directory '%0%' does not exist.", [$directory]));
186 throw new IllegalArgumentException($message->getText("Cannot copy %0% (it's neither a file nor a directory).", [$source]));
static getFiles($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false)
Definition: FileUtil.php:98
static basename($file)
Get the trailing name component of a path (locale independent)
Definition: FileUtil.php:327
IllegalArgumentException signals an exception in method arguments.
Definition: IllegalArgumentException.php:18
static getDirectories($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false)
Definition: FileUtil.php:138
FileUtil provides basic support for file functionality like HTTP file upload.
Definition: FileUtil.php:22
static getInstance($name, $dynamicConfiguration=[])
Definition: ObjectFactory.php:47
IOException signals an exception in i/o operations.
Definition: IOException.php:18
static uploadFile($mediaFile, $destName, $mimeTypes=null, $override=true)
Copy an uploaded file to a given destination (only if the mime type matches the given one).
Definition: FileUtil.php:32
static sanitizeFilename($file)
Get a sanitized filename code from: http://stackoverflow.com/questions/2021624/string-sanitizer-for-f...
Definition: FileUtil.php:275
static realpath($path)
Realpath function that also works for non existing paths code from http://www.php....
Definition: FileUtil.php:244
ObjectFactory implements the service locator pattern by wrapping a Factory instance and providing sta...
Definition: ObjectFactory.php:24
static fixFilename($file)
Fix the name of an existing file to be used with php file functions.
Definition: FileUtil.php:286