File

A File handling class

since

1.7.0

package

Joomla CMS

Methods

append

Append contents to a file

append(string file, string buffer, bool useStreams = false) : bool
static
since

3.6.0

Arguments

file

stringThe full file path

buffer

stringThe buffer to write

useStreams

boolUse streams

Response

boolTrue on success

copy

Copies a file

copy(string src, string dest, string path = null, bool useStreams = false) : bool
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

useStreams

boolTrue to use streams

Response

boolTrue on success

delete

Delete a file or array of files

delete(mixed file) : bool
static
since

1.7.0

Arguments

file

mixedThe file name or an array of file names

Response

boolTrue on success

exists

Wrapper for the standard file_exists function

exists(string file) : bool
static
since

1.7.0

Arguments

file

stringFile path

Response

boolTrue 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 = '', bool useStreams = false) : bool
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

useStreams

boolTrue to use streams

Response

boolTrue on success

read

Read the contents of a file

read(string filename, bool incpath = false, int amount, int chunksize = 8192, int 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

boolUse include path

amount

intAmount of file to read

chunksize

intSize of chunks to read

offset

intOffset 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, bool useStreams = false, bool allowUnsafe = false, bool safeFileOptions = array()) : bool
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

useStreams

boolTrue to use streams

allowUnsafe

boolAllow the upload of unsafe files

safeFileOptions

boolOptions to \JFilterInput::isSafeFile

Response

boolTrue on success

write

Write contents to a file

write(string file, string buffer, bool useStreams = false) : bool
static
since

1.7.0

Arguments

file

stringThe full file path

buffer

stringThe buffer to write

useStreams

boolUse streams

Response

boolTrue on success