PHP Class Pop\File\File

Author: Nick Sagona, III ([email protected])
Afficher le fichier Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Свойство Type Description
$allowed array Array of allowed file types.
$basename string Full basename of file, i.e. 'file.ext'
$dir string Full, absolute directory of file, i.e. '/some/dir/'
$ext string File extension, i.e. 'ext'
$filename string Full filename of file, i.e. 'file'
$fullpath string Full path and name of the file, i.e. '/some/dir/file.ext'
$mime string File mime type
$output string File output data.
$size integer File size in bytes

Méthodes publiques

Méthode Description
__construct ( string $file, array $types = null ) : File Constructor
addAllowedTypes ( array $types ) : void Set the allowed files types.
append ( string $data ) : File Append data to a file.
checkDupe ( string $file, string $dir = null ) : string Static method to check for a duplicate file, returning the next incremented filename, i.e. filename_1.txt
copy ( string $new, boolean $overwrite = false ) : File Copy the file object directly to another file on disk.
delete ( ) : void Delete the file object directly from disk.
getAllowedTypes ( ) : array Get the current allowed files types.
getBasename ( ) : string Get the basename.
getDir ( ) : string Get the directory.
getDirGroup ( ) : array Get the owner of the file. Works on POSIX file systems only
getDirOwner ( ) : array Get the owner of the file. Works on POSIX file systems only
getDirPermissions ( ) : string Get the permissions of the directory the file is in.
getExt ( ) : string Get the extension.
getFilename ( ) : string Get the filename.
getFullpath ( ) : string Get the fullpath.
getGroup ( ) : array Get the owner of the file. Works on POSIX file systems only
getMime ( ) : string Get the current file mime type.
getOwner ( ) : array Get the owner of the file. Works on POSIX file systems only
getPermissions ( ) : string Get the permissions of the file.
getSize ( ) : string Get the current file size.
getUser ( ) : array Get current user. Works on POSIX file systems only
isAllowed ( string $type ) : boolean Test if a certain file type is allowed.
isDir ( ) : boolean Is dir object.
isFile ( ) : boolean Is file object.
move ( string $new, boolean $overwrite = false ) : File Move the file object directly to another location on disk.
output ( boolean $download = false ) : File Output the file object directly.
read ( integer | string $off = null, integer | string $len = null ) : string Read data from a file.
save ( string $to = null, boolean $append = false ) : File Save the file object to disk.
setAllowedTypes ( array $types = null ) : void Set the allowed files types, overriding any previously allowed types.
setDirPermissions ( mixed $mode ) : File Change the permissions of the directory the file is in.
setMime ( string $mime ) : File Set the file mime type.
setPermissions ( mixed $mode ) : File Change the permissions of the file.
upload ( string $upload, string $file, integer $size, array $types = null ) : File Static method to upload a file and return a file object.
write ( string $data, boolean $append = false ) : File Write data to a file.

Méthodes protégées

Méthode Description
setFile ( string $file, array $types = null ) : void Set the file and its properties.

Method Details

__construct() public méthode

Instantiate the file object, either from a file on disk or as a new file.
public __construct ( string $file, array $types = null ) : File
$file string
$types array
Résultat File

addAllowedTypes() public méthode

Set the allowed files types.
public addAllowedTypes ( array $types ) : void
$types array
Résultat void

append() public méthode

Append data to a file.
public append ( string $data ) : File
$data string
Résultat File

checkDupe() public static méthode

Static method to check for a duplicate file, returning the next incremented filename, i.e. filename_1.txt
public static checkDupe ( string $file, string $dir = null ) : string
$file string
$dir string
Résultat string

copy() public méthode

Copy the file object directly to another file on disk.
public copy ( string $new, boolean $overwrite = false ) : File
$new string
$overwrite boolean
Résultat File

delete() public méthode

Delete the file object directly from disk.
public delete ( ) : void
Résultat void

getAllowedTypes() public méthode

Get the current allowed files types.
public getAllowedTypes ( ) : array
Résultat array

getBasename() public méthode

Get the basename.
public getBasename ( ) : string
Résultat string

getDir() public méthode

Get the directory.
public getDir ( ) : string
Résultat string

getDirGroup() public méthode

Get the owner of the file. Works on POSIX file systems only
public getDirGroup ( ) : array
Résultat array

getDirOwner() public méthode

Get the owner of the file. Works on POSIX file systems only
public getDirOwner ( ) : array
Résultat array

getDirPermissions() public méthode

Get the permissions of the directory the file is in.
public getDirPermissions ( ) : string
Résultat string

getExt() public méthode

Get the extension.
public getExt ( ) : string
Résultat string

getFilename() public méthode

Get the filename.
public getFilename ( ) : string
Résultat string

getFullpath() public méthode

Get the fullpath.
public getFullpath ( ) : string
Résultat string

getGroup() public méthode

Get the owner of the file. Works on POSIX file systems only
public getGroup ( ) : array
Résultat array

getMime() public méthode

Get the current file mime type.
public getMime ( ) : string
Résultat string

getOwner() public méthode

Get the owner of the file. Works on POSIX file systems only
public getOwner ( ) : array
Résultat array

getPermissions() public méthode

Get the permissions of the file.
public getPermissions ( ) : string
Résultat string

getSize() public méthode

Get the current file size.
public getSize ( ) : string
Résultat string

getUser() public méthode

Get current user. Works on POSIX file systems only
public getUser ( ) : array
Résultat array

isAllowed() public méthode

Test if a certain file type is allowed.
public isAllowed ( string $type ) : boolean
$type string
Résultat boolean

isDir() public méthode

Is dir object.
public isDir ( ) : boolean
Résultat boolean

isFile() public méthode

Is file object.
public isFile ( ) : boolean
Résultat boolean

move() public méthode

Move the file object directly to another location on disk.
public move ( string $new, boolean $overwrite = false ) : File
$new string
$overwrite boolean
Résultat File

output() public méthode

Output the file object directly.
public output ( boolean $download = false ) : File
$download boolean
Résultat File

read() public méthode

Read data from a file.
public read ( integer | string $off = null, integer | string $len = null ) : string
$off integer | string
$len integer | string
Résultat string

save() public méthode

Save the file object to disk.
public save ( string $to = null, boolean $append = false ) : File
$to string
$append boolean
Résultat File

setAllowedTypes() public méthode

Set the allowed files types, overriding any previously allowed types.
public setAllowedTypes ( array $types = null ) : void
$types array
Résultat void

setDirPermissions() public méthode

Change the permissions of the directory the file is in.
public setDirPermissions ( mixed $mode ) : File
$mode mixed
Résultat File

setFile() protected méthode

Set the file and its properties.
protected setFile ( string $file, array $types = null ) : void
$file string
$types array
Résultat void

setMime() public méthode

Set the file mime type.
public setMime ( string $mime ) : File
$mime string
Résultat File

setPermissions() public méthode

Change the permissions of the file.
public setPermissions ( mixed $mode ) : File
$mode mixed
Résultat File

upload() public static méthode

Static method to upload a file and return a file object.
public static upload ( string $upload, string $file, integer $size, array $types = null ) : File
$upload string
$file string
$size integer
$types array
Résultat File

write() public méthode

Write data to a file.
public write ( string $data, boolean $append = false ) : File
$data string
$append boolean
Résultat File

Property Details

$allowed protected_oe property

Array of allowed file types.
protected array $allowed
Résultat array

$basename protected_oe property

Full basename of file, i.e. 'file.ext'
protected string $basename
Résultat string

$dir protected_oe property

Full, absolute directory of file, i.e. '/some/dir/'
protected string $dir
Résultat string

$ext protected_oe property

File extension, i.e. 'ext'
protected string $ext
Résultat string

$filename protected_oe property

Full filename of file, i.e. 'file'
protected string $filename
Résultat string

$fullpath protected_oe property

Full path and name of the file, i.e. '/some/dir/file.ext'
protected string $fullpath
Résultat string

$mime protected_oe property

File mime type
protected string $mime
Résultat string

$output protected_oe property

File output data.
protected string $output
Résultat string

$size protected_oe property

File size in bytes
protected int $size
Résultat integer