This class represents a physical file. More...
Public Member Functions | |
| __construct ($guid=null) | |
| Loads an ElggFile entity. | |
| setFilename ($name) | |
| Set the filename of this file. | |
| getFilename () | |
| Return the filename. | |
| getFilenameOnFilestore () | |
| Return the filename of this file as it is/will be stored on the filestore, which may be different to the filename. | |
| getFilestoreSize ($prefix= '', $container_guid=0) | |
| Return the size of the filestore associated with this file. | |
| getMimeType () | |
| Get the mime type of the file. | |
| setMimeType ($mimetype) | |
| Set the mime type of the file. | |
| setDescription ($description) | |
| Set the optional file description. | |
| open ($mode) | |
| Open the file with the given mode. | |
| write ($data) | |
| Write data. | |
| read ($length, $offset=0) | |
| Read data. | |
| grabFile () | |
| Gets the full contents of this file. | |
| close () | |
| Close the file and commit changes. | |
| delete () | |
| Delete this file. | |
| seek ($position) | |
| Seek a position in the file. | |
| tell () | |
| Return the current position of the file. | |
| size () | |
| Return the size of the file in bytes. | |
| eof () | |
| Return a boolean value whether the file handle is at the end of the file. | |
| exists () | |
| Returns if the file exists. | |
| setFilestore (ElggFilestore $filestore) | |
| Set a filestore. | |
| save () | |
| Save the file. | |
Static Public Member Functions | |
| static | detectMimeType ($file=null, $default=null) |
| Detects mime types based on filename or actual file. | |
Protected Member Functions | |
| initializeAttributes () | |
| Set subtype to 'file'. | |
| getFilestore () | |
| Return a filestore suitable for saving this file. | |
This class represents a physical file.
Create a new ElggFile object and specify a filename, and optionally a FileStore (if one isn't specified then the default is assumed.)
Open the file using the appropriate mode, and you will be able to read and write to the file.
Optionally, you can also call the file's save() method, this will turn the file into an entity in the system and permit you to do things like attach tags to the file etc. This is not done automatically since there are many occasions where you may want access to file data on datastores using the ElggFile interface but do not want to create an Entity reference to it in the system (temporary files for example).
Definition at line 23 of file ElggFile.php.
| ElggFile::__construct | ( | $ | guid = null |
) |
Loads an ElggFile entity.
| int | $guid GUID of the ElggFile object |
Reimplemented from ElggObject.
Definition at line 46 of file ElggFile.php.
| ElggFile::close | ( | ) |
| ElggFile::delete | ( | ) |
Delete this file.
Reimplemented from ElggData.
Definition at line 271 of file ElggFile.php.
| static ElggFile::detectMimeType | ( | $ | file = null, |
|
| $ | default = null | |||
| ) | [static] |
Detects mime types based on filename or actual file.
| mixed | $file The full path of the file to check. For uploaded files, use tmp_name. | |
| mixed | $default A default. Useful to pass what the browser thinks it is. |
Definition at line 132 of file ElggFile.php.
| ElggFile::eof | ( | ) |
Return a boolean value whether the file handle is at the end of the file.
Definition at line 316 of file ElggFile.php.
| ElggFile::exists | ( | ) |
| ElggFile::getFilename | ( | ) |
| ElggFile::getFilenameOnFilestore | ( | ) |
Return the filename of this file as it is/will be stored on the filestore, which may be different to the filename.
Definition at line 79 of file ElggFile.php.
| ElggFile::getFilestore | ( | ) | [protected] |
Return a filestore suitable for saving this file.
This filestore is either a pre-registered filestore, a filestore as recorded in metadata or the system default.
Definition at line 351 of file ElggFile.php.
| ElggFile::getFilestoreSize | ( | $ | prefix = '', |
|
| $ | container_guid = 0 | |||
| ) |
Return the size of the filestore associated with this file.
| string | $prefix Storage prefix | |
| int | $container_guid The container GUID of the checked filestore |
Definition at line 91 of file ElggFile.php.
| ElggFile::getMimeType | ( | ) |
| ElggFile::grabFile | ( | ) |
Gets the full contents of this file.
Definition at line 244 of file ElggFile.php.
| ElggFile::initializeAttributes | ( | ) | [protected] |
Set subtype to 'file'.
Reimplemented from ElggObject.
Definition at line 35 of file ElggFile.php.
| ElggFile::open | ( | $ | mode | ) |
Open the file with the given mode.
| string | $mode Either read/write/append |
Definition at line 182 of file ElggFile.php.
| ElggFile::read | ( | $ | length, | |
| $ | offset = 0 | |||
| ) |
Read data.
| int | $length Amount to read. | |
| int | $offset The offset to start from. |
Definition at line 233 of file ElggFile.php.
| ElggFile::save | ( | ) |
Save the file.
Write the file's data to the filestore and save the corresponding entity.
Reimplemented from ElggObject.
Definition at line 411 of file ElggFile.php.
| ElggFile::seek | ( | $ | position | ) |
Seek a position in the file.
| int | $position Position in bytes |
Definition at line 285 of file ElggFile.php.
| ElggFile::setDescription | ( | $ | description | ) |
Set the optional file description.
| string | $description The description. |
Definition at line 171 of file ElggFile.php.
| ElggFile::setFilename | ( | $ | name | ) |
Set the filename of this file.
| string | $name The filename. |
Definition at line 60 of file ElggFile.php.
| ElggFile::setFilestore | ( | ElggFilestore $ | filestore | ) |
Set a filestore.
| ElggFilestore | $filestore The file store. |
Definition at line 340 of file ElggFile.php.
| ElggFile::setMimeType | ( | $ | mimetype | ) |
Set the mime type of the file.
| string | $mimetype The mimetype |
Definition at line 119 of file ElggFile.php.
| ElggFile::size | ( | ) |
| ElggFile::tell | ( | ) |
Return the current position of the file.
Definition at line 296 of file ElggFile.php.
| ElggFile::write | ( | $ | data | ) |
Write data.
| string | $data The data |
Definition at line 219 of file ElggFile.php.
1.6.3