Clean Filename PHP

<?php
         * Clean the file name for security
         *
         * @access      public
         * @param       string
         * @return      string
         */

        function clean_file_name($filename)
        {
                $bad = array(
                                                "<!--",
                                                "-->",
                                                "'",
                                                "< ",
                                                ">",
                                                '"',
                                                '&',
                                                '$',
                                                '=',
                                                ';',
                                                '?',
                                                '/',
                                                "%20",
                                                "%22",
                                                "%3c",          // <                                                 "%253c",        // <
                                                "%3e",          // >
                                                "%0e",          // >
                                                "%28",          // (
                                                "%29",          // )
                                                "%2528",        // (
                                                "%26",          // &
                                                "%24",          // $
                                                "%3f",          // ?
                                                "%3b",          // ;
                                                "%3d"           // =
                                        );
                                       
                $filename = str_replace($bad, '', $filename);
 
                return stripslashes($filename);
        }
 ?>
Processing your request, Please wait....

No Responses to “Clean Filename PHP”

Comments (Your Comments)

Leave a Reply

You must be logged in to post a comment.