Hello friends,
Today we understand about the filesystem in Joomla. Joomla contains pre-defined functions and classes to perform file operations such as delete, upload, get extension, get filename etc. Filesystem package includes 4 classes:
- JFile:: (file.php)
- JFolder:: (folder.php)
- JPath:: (path.php)
- JArchive:: (archive.php)
In this tutorial, we will discuss JFile:: class. This class is the base of the file handling in Joomla which is stored in libraries/joomla/filesystem/file.php. Some of the common method of this library is described as follows:
- getExt():
This function in Joomla is used to find out the extension of the file. You need to pass the name of the file whose extension you need to find out.
Syntax:
JFile::getExt($filename);
$filename is the name of the file.
- stripExt(): This function is used to get the filename without extension in Joomla.
Syntax:
$name = JFile::stripExt($filename);
$filename is the name of the file whose extension you need to find out.
- makeSafe(): This function is used to remove odd characters from the file to make the file safe for use.
Syntax:
$safefilename = JFile::makeSafe($filename);
$filename is the name of the file.
- delete(): This function is used to delete a file in Joomla.
Syntax:
JFile::delete($path.$file);
$path is the file path and $file is the name of the file.
- upload():
This function is used to upload a file from source to destination.
Syntax:
JFile::upload($src, $dest);
$src is the source of the file and $dest is the destination where you want to upload the file.
0 Comment(s)