CWIS Developer Documentation

- Home
- Main Page
- 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
| File ($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.

## 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 197 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 254 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 205 of file File.php.

File::File | ( |  | $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 38 of file File.php.

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

File::GetLength | ( |  | ) |

Gets the length of the file.

Returns
  The length of the file.

Definition at line 184 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 231 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 220 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 271 of file File.php.

References Id(), and Name().

Referenced by Delete(), and File().

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 300 of file File.php.

File::GetType | ( |  | ) |

Gets the file's type.

Returns
  The file's type.

Definition at line 190 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 172 of file File.php.

Referenced by Delete(), File(), and GetNameOfStoredFile().

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 178 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 213 of file File.php.

File::Status | ( |  | ) |

Gets the object's status.

Returns
  The status code of the object.

Definition at line 166 of file File.php.

Referenced by File().

Here is the caller graph for this function:

## Member Data Documentation

const File::FILESTAT_COPYERROR = 1

Definition at line 19 of file File.php.

const File::FILESTAT_DOESNOTEXIST = 4

Definition at line 22 of file File.php.

const File::FILESTAT_OK = 0

Definition at line 18 of file File.php.

const File::FILESTAT_PARAMERROR = 2

Definition at line 20 of file File.php.

const File::FILESTAT_UNREADABLE = 5

Definition at line 23 of file File.php.

const File::FILESTAT_ZEROLENGTH = 3

Definition at line 21 of file File.php.

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

- objects/File.php