PHP Class ElggFile, Elgg

Author: Curverider Ltd
Inheritance: extends ElggObject
Datei anzeigen Open project: elgg/elgg Class Usage Examples

Public Methods

Method Description
__sleep ( ) : string[] Get property names to serialize.
acceptUploadedFile ( Symfony\Component\HttpFoundation\File\UploadedFile $upload ) : boolean Writes contents of the uploaded file to an instance of ElggFile
close ( ) : boolean Close the file and commit changes
delete ( boolean $follow_symlinks = true ) : boolean Delete this file.
detectMimeType ( mixed $file = null, mixed $default = null ) : mixed Detects mime types based on filename or actual file.
eof ( ) : boolean Return a boolean value whether the file handle is at the end of the file
exists ( ) : boolean Returns if the file exists
getFilename ( ) : string Return the filename.
getFilenameOnFilestore ( ) : string Return the filename of this file as it is/will be stored on the filestore, which may be different to the filename.
getFilestoreSize ( string $prefix = '', integer $container_guid ) : integer Return the size of the filestore associated with this file
getMimeType ( ) : string Get the mime type of the file.
getModifiedTime ( ) : integer Returns file modification time
getSimpleType ( ) : string Get the simple type of the file.
getSize ( ) : integer Return the size of the file in bytes.
grabFile ( ) : mixed Gets the full contents of this file.
open ( string $mode ) : resource Open the file with the given mode
read ( integer $length, integer $offset ) : mixed Read data.
seek ( integer $position ) : void Seek a position in the file.
setDescription ( string $description ) : boolean Set the optional file description.
setFilename ( string $name ) : void Set the filename of this file.
setMimeType ( string $mimetype ) : boolean Set the mime type of the file.
setModifiedTime ( ) : boolean Updates modification time of the file and clears stats cache for the file
tell ( ) : integer Return the current position of the file.
transfer ( integer $owner_guid, string $filename = null ) : boolean Transfer a file to a new owner and sets a new filename, copies file contents to a new location.
write ( string $data ) : boolean Write data.

Protected Methods

Method Description
getFilestore ( ) : ElggDiskFilestore Return the system filestore based on dataroot.
initializeAttributes ( ) : void Set subtype to 'file'.

Method Details

__sleep() public method

Get property names to serialize.
public __sleep ( ) : string[]
return string[]

acceptUploadedFile() public method

Writes contents of the uploaded file to an instance of ElggFile
public acceptUploadedFile ( Symfony\Component\HttpFoundation\File\UploadedFile $upload ) : boolean
$upload Symfony\Component\HttpFoundation\File\UploadedFile Uploaded file object
return boolean

close() public method

Close the file and commit changes
public close ( ) : boolean
return boolean

delete() public method

Delete this file.
public delete ( boolean $follow_symlinks = true ) : boolean
$follow_symlinks boolean If true, will also delete the target file if the current file is a symlink
return boolean

detectMimeType() public method

Detects mime types based on filename or actual file.
Since: 1.7.12
public detectMimeType ( mixed $file = null, mixed $default = null ) : mixed
$file mixed The full path of the file to check. For uploaded files, use tmp_name.
$default mixed A default. Useful to pass what the browser thinks it is.
return mixed Detected type on success, false on failure.

eof() public method

Return a boolean value whether the file handle is at the end of the file
public eof ( ) : boolean
return boolean

exists() public method

Returns if the file exists
public exists ( ) : boolean
return boolean

getFilename() public method

Return the filename.
public getFilename ( ) : string
return string

getFilenameOnFilestore() public method

Return the filename of this file as it is/will be stored on the filestore, which may be different to the filename.
public getFilenameOnFilestore ( ) : string
return string

getFilestore() protected method

Return the system filestore based on dataroot.
protected getFilestore ( ) : ElggDiskFilestore
return ElggDiskFilestore

getFilestoreSize() public method

Return the size of the filestore associated with this file
public getFilestoreSize ( string $prefix = '', integer $container_guid ) : integer
$prefix string Storage prefix
$container_guid integer The container GUID of the checked filestore
return integer

getMimeType() public method

Returns mimetype metadata value if set, otherwise attempts to detect it.
public getMimeType ( ) : string
return string

getModifiedTime() public method

Returns file modification time
public getModifiedTime ( ) : integer
return integer

getSimpleType() public method

Returns simpletype metadata value if set, otherwise parses it from mimetype
See also: elgg_get_file_simple_type
public getSimpleType ( ) : string
return string 'document', 'audio', 'video', or 'general' if the MIME type was unrecognized

getSize() public method

Return the size of the file in bytes.
Since: 1.9
public getSize ( ) : integer
return integer

grabFile() public method

Gets the full contents of this file.
public grabFile ( ) : mixed
return mixed The file contents.

initializeAttributes() protected method

Set subtype to 'file'.
protected initializeAttributes ( ) : void
return void

open() public method

Open the file with the given mode
public open ( string $mode ) : resource
$mode string Either read/write/append
return resource File handler

read() public method

Read data.
public read ( integer $length, integer $offset ) : mixed
$length integer Amount to read.
$offset integer The offset to start from.
return mixed Data or false

seek() public method

Seek a position in the file.
public seek ( integer $position ) : void
$position integer Position in bytes
return void

setDescription() public method

Set the optional file description.
public setDescription ( string $description ) : boolean
$description string The description.
return boolean

setFilename() public method

Set the filename of this file.
public setFilename ( string $name ) : void
$name string The filename.
return void

setMimeType() public method

Set the mime type of the file.
public setMimeType ( string $mimetype ) : boolean
$mimetype string The mimetype
return boolean

setModifiedTime() public method

Updates modification time of the file and clears stats cache for the file
public setModifiedTime ( ) : boolean
return boolean

tell() public method

Return the current position of the file.
public tell ( ) : integer
return integer The file position

transfer() public method

This is an alternative to using rename() which fails to move files to a non-existent directory under new owner's filestore directory
public transfer ( integer $owner_guid, string $filename = null ) : boolean
$owner_guid integer New owner's guid
$filename string New filename (uses old filename if not set)
return boolean

write() public method

Write data.
public write ( string $data ) : boolean
$data string The data
return boolean