API17

JFile::makeSafe

From Joomla! Documentation

Revision as of 17:58, 10 May 2013 by JoomlaWikiBot (talk | contribs) (JoomlaWikiBot moved page JFile::makeSafe/11.1 to API17:JFile::makeSafe without leaving a redirect: Robot: Moved page)

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.

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

See also[edit]

Template:SeeAlso:JFile::makeSafe [Edit See Also]

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


<CodeExamplesForm />