API17

JFile::makeSafe: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 4: Line 4:
Makes file name safe to use.  
Makes file name safe to use.  


{{subst:Description:JFile::makeSafe}}
 


<source lang="php">
<source lang="php">
Line 30: Line 30:
* {{JVer|11.1}} Subpackage [[API17:Subpackage_Filesystem|Filesystem]]
* {{JVer|11.1}} Subpackage [[API17:Subpackage_Filesystem|Filesystem]]
* [[API17:JFile::makeSafe|Other versions of JFile::makeSafe]]
* [[API17:JFile::makeSafe|Other versions of JFile::makeSafe]]
{{subst:SeeAlso:JFile::makeSafe}}
 


===User contributed notes===
===User contributed notes===
Line 46: Line 46:




<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
noresultsheader=\n
noresultsheader=\n
category=JFile::makeSafe
category=JFile::makeSafe
category=CodeExample
namespace=CodeExample
category=MethodExample
category=MethodExample
include=*
include=*

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