API17:JFile::makeSafe
From Joomla! Documentation
(Difference between revisions)
(Layout updates) |
m (→User contributed notes: added example) |
||
| (One intermediate revision by one user not shown) | |||
| Line 8: | Line 8: | ||
<nowiki>[</nowiki>[[Description:JFile::makeSafe|Edit Descripton]]<nowiki>]</nowiki> | <nowiki>[</nowiki>[[Description:JFile::makeSafe|Edit Descripton]]<nowiki>]</nowiki> | ||
</span> | </span> | ||
| − | |||
| − | |||
| − | |||
<source lang="php"> | <source lang="php"> | ||
| − | public static | + | public static function makeSafe ($file) |
</source> | </source> | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 27: | Line 24: | ||
|- | |- | ||
|} | |} | ||
| − | + | * '''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 [[JFile/11.1|JFile]] | ||
| + | * {{JVer|11.1}} Subpackage [[Subpackage_Filesystem/11.1|Filesystem]] | ||
| + | * [[JFile::makeSafe|Other versions of JFile::makeSafe]] | ||
| + | {{SeeAlso:JFile::makeSafe}} | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[</nowiki>[[SeeAlso:JFile::makeSafe|Edit See Also]]<nowiki>]</nowiki> | <nowiki>[</nowiki>[[SeeAlso:JFile::makeSafe|Edit See Also]]<nowiki>]</nowiki> | ||
</span> | </span> | ||
| − | + | ===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> | ||
| + | |||
| + | |||
<CodeExamplesForm /> | <CodeExamplesForm /> | ||
<dpl> | <dpl> | ||
| Line 48: | Line 57: | ||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
| + | namespace=CodeExample | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
<noinclude>[[Category:JFile]][[Category:JFile::makeSafe]]</noinclude> | <noinclude>[[Category:JFile]][[Category:JFile::makeSafe]]</noinclude> | ||
Revision as of 04:02, 1 July 2012
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
JFile::makeSafe
Description
Makes file name safe to use.
Description:JFile::makeSafe [Edit Descripton]
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
SeeAlso:JFile::makeSafe [Edit See Also]
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']);
<CodeExamplesForm />
