API16

JFile/makeSafe

From Joomla! Documentation

< API16:JFile
Revision as of 17:38, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Makes file name safe to use <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </s...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

[Edit Descripton]

Template:Description:JFile/makeSafe

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);
}

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

Examples[edit]

<CodeExamplesForm />