API17

Difference between revisions of "JFile::makeSafe"

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 22:01, 24 March 2017

The "API17" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Joomla 11.1 JFile::makeSafe[edit]

Description[edit]

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[edit]


User contributed notes[edit]

Example[edit]

		//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[edit]