JFile::makeSafe: Difference between revisions
From Joomla! Documentation
Bulk upload by Doxiki2 |
m preparing for archive only |
||
| (7 intermediate revisions by 3 users not shown) | |||
| Line 4: | Line 4: | ||
Makes file name safe to use. | Makes file name safe to use. | ||
<source lang="php"> | <source lang="php"> | ||
public static | public static function makeSafe ($file) | ||
</source> | </source> | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 27: | Line 22: | ||
|- | |- | ||
|} | |} | ||
* '''Returns''' string The sanitised string | |||
string The sanitised string | * '''Defined''' on line 60 of libraries/joomla/filesystem/file.php | ||
* '''Since''' {{JVer|11.1 }} | |||
libraries/joomla/filesystem/file.php | |||
===See also=== | ===See also=== | ||
* {{JVer|11.1}} '''JFile::makeSafe source code''' on [[jplatform:filesystem/file.php#cl-52|BitBucket]] | |||
* {{JVer|11.1}} Class [[API17:JFile|JFile]] | |||
* {{JVer|11.1}} Subpackage [[API17:Subpackage_Filesystem|Filesystem]] | |||
* | * [[API17:JFile::makeSafe|Other versions of JFile::makeSafe]] | ||
* [[JFile::makeSafe|Other versions of | |||
===Examples=== | ===User contributed notes=== | ||
===Example=== | |||
<source lang="php"> | |||
//Retrieve file details from uploaded file, sent from upload form | |||
$file = JRequest::getVar('upload_file', null, 'files', 'array'); | |||
//Import filesystem libraries. Perhaps not necessary, but does not hurt | |||
jimport('joomla.filesystem.file'); | |||
//Clean up filename to get rid of strange characters like spaces etc | |||
$filename = JFile::makeSafe($file['name']); | |||
</source> | |||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=JFile::makeSafe | category=JFile::makeSafe | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
namespace=CodeExample | |||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
<noinclude>[[Category: | <noinclude>[[Category:Platform 11.1]][[Category:Archived pages API17]]</noinclude> | ||
Latest revision as of 03:01, 25 March 2017
JFile::makeSafe
Description
Makes file name safe to use.
public static function makeSafe ($file)
| Parameter | Type | Default | Description |
|---|---|---|---|
| $file | string | The name of the file [not full path] |
- Returns string The sanitised string
- Defined on line 60 of libraries/joomla/filesystem/file.php
- Since

See also
JFile::makeSafe source code on BitBucket
Class JFile
Subpackage Filesystem- Other versions of JFile::makeSafe
User contributed notes
Example
//Retrieve file details from uploaded file, sent from upload form
$file = JRequest::getVar('upload_file', null, 'files', 'array');
//Import filesystem libraries. Perhaps not necessary, but does not hurt
jimport('joomla.filesystem.file');
//Clean up filename to get rid of strange characters like spaces etc
$filename = JFile::makeSafe($file['name']);
Code Examples