API17

JFile::makeSafe: Difference between revisions

From Joomla! Documentation

Doxiki2 (talk | contribs)
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.  


{{Description:JFile::makeSafe}}
 
<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[Description:JFile::makeSafe|Edit Descripton]]<nowiki>]</nowiki>
</span>
===Since===
{{JVer|11.1 }}
===Synopsis===
<source lang="php">
<source lang="php">
public static JFile::makeSafe ($file)
public static function makeSafe ($file)
</source>
</source>
{| class="wikitable"
{| class="wikitable"
Line 27: Line 22:
|-
|-
|}
|}
===Returns===
* '''Returns''' string The sanitised string
string The sanitised string
* '''Defined''' on line 60 of libraries/joomla/filesystem/file.php
===Defined in===
* '''Since''' {{JVer|11.1 }}
libraries/joomla/filesystem/file.php
===Referenced by===
===See also===
===See also===
<span class="editsection" style="font-size:76%;">
* {{JVer|11.1}} '''JFile::makeSafe source code''' on [[jplatform:filesystem/file.php#cl-52|BitBucket]]
<nowiki>[</nowiki>[[SeeAlso:JFile::makeSafe|Edit See Also]]<nowiki>]</nowiki>
* {{JVer|11.1}} Class [[API17:JFile|JFile]]
</span>
* {{JVer|11.1}} Subpackage [[API17:Subpackage_Filesystem|Filesystem]]
* [[JFile/11.1|JFile]]
* [[API17:JFile::makeSafe|Other versions of JFile::makeSafe]]
* [[JFile::makeSafe|Other versions of this method]]
 
{{SeeAlso:JFile::makeSafe}}
 
===Examples===
===User contributed notes===
<CodeExamplesForm />
===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
category=CodeExample
namespace=CodeExample
category=MethodExample
category=MethodExample
include=*
include=*
namespace=CodeExample
format= ,,,
format= ,,,
</dpl>
</dpl>
<noinclude>[[Category:JFile]][[Category:JFile::makeSafe]]</noinclude>
<noinclude>[[Category:Platform 11.1]][[Category:Archived pages API17]]</noinclude>

Latest revision as of 03:01, 25 March 2017

Joomla 11.1 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 Joomla 11.1

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']);


Code Examples