CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
File Class Reference

Class representing a stored (usually uploaded) file. More...

## Public Member Functions
| __construct ($IdOrFileName, $ResourceId=NULL, $FieldId=NULL, $DesiredFileName=NULL, $CheckFileLength=TRUE)
| Constructs a File object using either an existing file or a new file. More...
| Status ()
| Gets the object's status. More...
| Id ()
| Gets the object's ID. More...
| Name ()
| Gets the name of the object. More...
| GetLength ()
| Gets the length of the file. More...
| GetType ()
| Gets the file's type. More...
| Comment ($NewValue=DB_NOVALUE)
| Gets or sets the comment on the file. More...
| FieldId ($NewValue=DB_NOVALUE)
| Gets or sets the field ID of the File. More...
| ResourceId ($NewValue=DB_NOVALUE)
| Gets or sets the resource ID of the File. More...
| GetMimeType ()
| Gets the MIME type of the file. More...
| GetLink ()
| Returns the relative download link to download the file. More...
| Delete ()
| Deletes the file and removes its entry from the database. More...
| GetNameOfStoredFile ()
| Returns the relative link to the stored file. More...

## Static Public Member Functions
static | GetStorageDirectory ()
| Get file storage directory. More...

## Public Attributes
const | FILESTAT_OK = 0
const | FILESTAT_COPYERROR = 1
const | FILESTAT_PARAMERROR = 2
const | FILESTAT_ZEROLENGTH = 3
const | FILESTAT_DOESNOTEXIST = 4
const | FILESTAT_UNREADABLE = 5

## Detailed Description

Class representing a stored (usually uploaded) file.

Definition at line 13 of file File.php.

## Constructor & Destructor Documentation

File::__construct | ( |  | $IdOrFileName,
|  |  | $ResourceId = `NULL`,
|  |  | $FieldId = `NULL`,
|  |  | $DesiredFileName = `NULL`,
|  |  | $CheckFileLength = `TRUE`
| ) |  |

Constructs a File object using either an existing file or a new file.

Parameters

  mixed | $IdOrFileName | The ID of the file if it is already in the database, or the file name if it is to be added to the database.
  int | $ResourceId | The ID of the corresponding resource if the file is being added. (OPTIONAL)
  int | $FieldId | The ID of the corresponding field if the file is being added. (OPTIONAL)
  string | $DesiredFileName | The desired name of the file if it is being added. (OPTIONAL)
  bool | $CheckFileLength | Whether to check the length of the file if it is being added. (OPTIONAL)

Definition at line 39 of file File.php.

References GetNameOfStoredFile(), Id(), and Status().

## Member Function Documentation

File::Comment | ( |  | $NewValue = `DB_NOVALUE` | ) |

Gets or sets the comment on the file.

Parameters

  string | $NewValue | The new comment on the file. (OPTIONAL)

Returns
  The comment on the file.

Definition at line 248 of file File.php.

File::Delete | ( |  | ) |

Deletes the file and removes its entry from the database.

Other methods are invalid after calling this.

Definition at line 309 of file File.php.

References GetNameOfStoredFile(), and Id().

File::FieldId | ( |  | $NewValue = `DB_NOVALUE` | ) |

Gets or sets the field ID of the File.

Parameters

  int | $NewValue | The new field ID of the File. (OPTIONAL)

Returns
  The field ID of the File.

Definition at line 258 of file File.php.

File::GetLength | ( |  | ) |

Gets the length of the file.

Returns
  The length of the file.

Definition at line 229 of file File.php.

File::GetLink | ( |  | ) |

Returns the relative download link to download the file.

If .htaccess files are supported, the redirect that includes the file name is used.

Returns
  The relative link to download the file.

Definition at line 288 of file File.php.

References Name().

File::GetMimeType | ( |  | ) |

Gets the MIME type of the file.

Returns
  The MIME type of the file.

Definition at line 277 of file File.php.

References GetType().

File::GetNameOfStoredFile | ( |  | ) |

Returns the relative link to the stored file.

Returns
  The relative link to the stored file

Definition at line 326 of file File.php.

References Id(), and Name().

Referenced by __construct(), and Delete().

Here is the caller graph for this function:

static File::GetStorageDirectory | ( |  | ) |
| static

Get file storage directory.

Returns
  string Relative directory path (with no trailing slash).

Definition at line 355 of file File.php.

References Id().

File::GetType | ( |  | ) |

Gets the file's type.

Returns
  The file's type.

Definition at line 238 of file File.php.

Referenced by GetMimeType().

Here is the caller graph for this function:

File::Id | ( |  | ) |

Gets the object's ID.

Returns
  The ID of the object.

Definition at line 211 of file File.php.

Referenced by __construct(), Delete(), GetNameOfStoredFile(), and GetStorageDirectory().

Here is the caller graph for this function:

File::Name | ( |  | ) |

Gets the name of the object.

Returns
  The name of the file.

Definition at line 220 of file File.php.

Referenced by GetLink(), and GetNameOfStoredFile().

Here is the caller graph for this function:

File::ResourceId | ( |  | $NewValue = `DB_NOVALUE` | ) |

Gets or sets the resource ID of the File.

Parameters

  int | $NewValue | The new resource ID of the File. (OPTIONAL)

Returns
  The resource ID of the File.

Definition at line 268 of file File.php.

File::Status | ( |  | ) |

Gets the object's status.

Returns
  The status code of the object.

Definition at line 202 of file File.php.

Referenced by __construct().

Here is the caller graph for this function:

## Member Data Documentation

const File::FILESTAT_COPYERROR = 1

Definition at line 20 of file File.php.

const File::FILESTAT_DOESNOTEXIST = 4

Definition at line 23 of file File.php.

const File::FILESTAT_OK = 0

Definition at line 19 of file File.php.

Referenced by UserEditingUI\UploadFiles().

const File::FILESTAT_PARAMERROR = 2

Definition at line 21 of file File.php.

const File::FILESTAT_UNREADABLE = 5

Definition at line 24 of file File.php.

const File::FILESTAT_ZEROLENGTH = 3

Definition at line 22 of file File.php.

Referenced by UserEditingUI\UploadFiles().

The documentation for this class was generated from the following file:

- objects/File.php