API16

JFile/makeSafe

From Joomla! Documentation

< API16:JFile
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API16" 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.

Description[edit]

Makes file name safe to use


<! removed transcluded page call, red link never existed >

Syntax[edit]

makeSafe($file)
Parameter Name Default Value Description
$file $file The name of the file [not full path]

Returns[edit]

string The sanitised string

Defined in[edit]

libraries/joomla/filesystem/file.php

Importing[edit]

jimport( 'joomla.filesystem.file' );

Source Body[edit]

function makeSafe($file) {
        $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#');
        return preg_replace($regex, '', $file);
}


<! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]