File
A File handling class
| since |
1.0 |
|---|---|
| package |
Joomla Framework |
Methods
copy
Copies a file
copy( src, dest, path = null, useStreams = false) :
| since |
1.0 |
|---|---|
| throws |
|
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( file) :
| since |
1.0 |
|---|---|
| throws |
Arguments
- file
mixedThe file name or an array of file names
Response
boolTrue on success
exists
Wrapper for the standard file_exists function
exists( file) :
Arguments
- file
stringFile path
Response
boolTrue if path is a file
getExt
Gets the extension of a file name
getExt( file) :
| since |
3.0.0 |
|---|
Arguments
- file
stringThe file name
Response
stringThe file extension
invalidateFileCache
Invalidate any opcache immediately for a file if opcache* functions are enabled and the file is a PHP file.
invalidateFileCache( file) :
Arguments
- file
stringThe path to the file just written to, to flush from opcache
Response
void
makeSafe
Makes the file name safe to use
makeSafe( file, mixed||string|int stripChars = ['#^.#']) :
| since |
1.0 |
|---|
Arguments
- file
stringThe name of the file [not full path]- stripChars
array<string|int, mixed>Array of regex (by default will remove any leading periods)
Response
stringThe sanitised string
move
Moves a file
move( src, dest, path = '', useStreams = false) :
| since |
1.0 |
|---|---|
| throws |
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
stripExt
Strips the last extension off of a file name
stripExt( file) :
| since |
1.0 |
|---|
Arguments
- file
stringThe file name
Response
stringThe file name without the extension
upload
Moves an uploaded file to a destination folder
upload( src, dest, useStreams = false) :
| since |
1.0 |
|---|---|
| throws |
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
Response
boolTrue on success
write
Write contents to a file
write( file, buffer, useStreams = false, appendToFile = false) :
| since |
1.0 |
|---|
Arguments
- file
stringThe full file path- buffer
stringThe buffer to write- useStreams
boolUse streams- appendToFile
boolAppend to the file and not overwrite it.
Response
boolTrue on success
Properties
canFlushFileCache
true if OPCache enabled, and we have permission to invalidate files
| since |
3.2.0 |
|---|
Type(s)
bool