This is documentation for Kohana v2.3.x.
Status | Final Draft |
---|---|
Todo | Proofread |
A helper designed to manipulate files and filenames.
'mime' finds the MIME-type of a file first by using PHP's built-in database and then Kohana's MIME configuration file (system/config/mimes.php). The parameters are:
Example:
$file = 'my_movie.ogg' echo $file.' ('.file::mime($file).')';
my_movie.ogg (application/ogg)
'split' splits a file into pieces matching a specific size indicated in megabytes. The parameters are:
Example:
$file = 'humpty_dumpty.mp3'; // pretend it is 7.8 MB large echo (file_exists($file)) ? file::split($file,FALSE,2) : 'can not find file!' ;
4
Directory listing:
-rwxrwxrwx 1 www-data www-data 8186302 2008-05-06 20:11 humpty_dumpty.mp3 -rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.001 -rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.002 -rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.003 -rw-r--r-- 1 www-data www-data 1894846 2008-05-06 20:15 humpty_dumpty.mp3.004
'join' joins splited files (possibly by file::split()), assuming a .### extension. The parameters are:
Example:
$file_in = 'humpty_dumpty.mp3'; // from our last example $file_out = 'humpty_dumpty-back_together_again.mp3'; // output name echo file::join($file_in,$file_out);
4
Directory listing:
-rwxrwxrwx 1 www-data www-data 8186302 2008-05-06 20:11 humpty_dumpty.mp3 -rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.001 -rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.002 -rw-r--r-- 1 www-data www-data 2097152 2008-05-06 20:15 humpty_dumpty.mp3.003 -rw-r--r-- 1 www-data www-data 1894846 2008-05-06 20:15 humpty_dumpty.mp3.004 -rw-r--r-- 1 www-data www-data 8186302 2008-05-06 20:17 humpty_dumpty-back_together_again.mp3