File

A File handling class

since

1.7.0

Methods

append

Append contents to a file

append(string $file, string $buffer, boolean $use_streams = false) : boolean
static
since

3.6.0

Arguments

$file

stringThe full file path

$buffer

stringThe buffer to write

$use_streams

booleanUse streams

Response

booleanTrue on success

copy

Copies a file

copy(string $src, string $dest, string $path = null, boolean $use_streams = false) : boolean
static
since

1.7.0

Arguments

$src

stringThe path to the source file

$dest

stringThe path to the destination file

$path

stringAn optional base path to prefix to the file names

$use_streams

booleanTrue to use streams

Response

booleanTrue on success

delete

Delete a file or array of files

delete(mixed $file) : boolean
static
since

1.7.0

Arguments

$file

mixedThe file name or an array of file names

Response

booleanTrue on success

exists

Wrapper for the standard file_exists function

exists(string $file) : boolean
static
since

1.7.0

Arguments

$file

stringFile path

Response

booleanTrue if path is a file

getExt

Gets the extension of a file name

getExt(string $file) : string
static
since

1.7.0

Arguments

$file

stringThe file name

Response

stringThe file extension

getName

Returns the name, without any path.

getName(string $file) : string
static deprecated
since

1.7.0

deprecated

4.0 - Use basename() instead.

Arguments

$file

stringFile path

Response

stringfilename

makeSafe

Makes file name safe to use

makeSafe(string $file) : string
static
since

1.7.0

Arguments

$file

stringThe name of the file [not full path]

Response

stringThe sanitised string

move

Moves a file

move(string $src, string $dest, string $path = '', boolean $use_streams = false) : boolean
static
since

1.7.0

Arguments

$src

stringThe path to the source file

$dest

stringThe path to the destination file

$path

stringAn optional base path to prefix to the file names

$use_streams

booleanTrue to use streams

Response

booleanTrue on success

read

Read the contents of a file

read(string $filename, boolean $incpath = false, integer $amount, integer $chunksize = 8192, integer $offset) : mixed
static deprecated
since

1.7.0

deprecated

4.0 - Use the native file_get_contents() instead.

Arguments

$filename

stringThe full file path

$incpath

booleanUse include path

$amount

integerAmount of file to read

$chunksize

integerSize of chunks to read

$offset

integerOffset of the file

Response

mixedReturns file contents or boolean False if failed

stripExt

Strips the last extension off of a file name

stripExt(string $file) : string
static
since

1.7.0

Arguments

$file

stringThe file name

Response

stringThe file name without the extension

upload

Moves an uploaded file to a destination folder

upload(string $src, string $dest, boolean $use_streams = false, boolean $allow_unsafe = false, boolean $safeFileOptions = array()) : boolean
static
since

1.7.0

Arguments

$src

stringThe name of the php (temporary) uploaded file

$dest

stringThe path (including filename) to move the uploaded file to

$use_streams

booleanTrue to use streams

$allow_unsafe

booleanAllow the upload of unsafe files

$safeFileOptions

booleanOptions to \JFilterInput::isSafeFile

Response

booleanTrue on success

write

Write contents to a file

write(string $file, string $buffer, boolean $use_streams = false) : boolean
static
since

1.7.0

Arguments

$file

stringThe full file path

$buffer

stringThe buffer to write

$use_streams

booleanUse streams

Response

booleanTrue on success