Wednesday, May 7, 2014

check valid Extension in php

<?php
$allowed_ext = array(
             'jpg'    =>    true,
            'gif'    =>    true,
            'png'    =>    true
     );

    function easy_checkvalid_ext($ext,$allowed_ext)
    {
     
     if($allowed_ext[$ext])
        {
            return true;
        }
       else
        {
           return false;
       }  
    
       }

 $validfile = easy_checkvalid_ext('jpg',$allowed_image_format);

if ( !$validfile)
echo "not a valid file type";
?>

No comments:

Post a Comment