Is there a quicker way to look up all image, audio and video file types in both client and server side
<p>Below I have 3 javascript functions which checks for a legitimate file extension for their files. The problem is that if I am doing it the way I am implementing it, I will have a very large case statement for each function stating which file extensions are legitmate to use. So what my question is that except doing </p>

<pre><code>`case:jpeg: 
case:jpg:
case:png`
</code></pre>

<p>and etc. Is there a quick way to create a case statment that checks for all legitimate image file extension types, all legitimate video file extension types and all legitimate audio file extension types?</p>

<p>Below is the 3 javascript functions I am currently using to validate file extension types for images, videos and audio:</p>

<p>IMAGE:</p>

<pre><code>   function imageValidation(imageuploadform) {

        var val = $(imageuploadform).find(".fileImage").val();
        switch(val.substring(val.lastIndexOf('.') + 1).toLowerCase()){
            case 'gif':
            case 'jpg': 
            case 'jpeg':
            case 'pjpeg':
            case 'png':
                 return true;

            case '':
                $(imageuploadform).find(".fileImage").val();
                alert("To upload an image, please select an Image File");
                return false;

            default:
                alert("To upload an image, please select a valild file extension.");
                return false;

        }

        return false;

}
</code></pre>

<p>VIDEO:</p>

<pre><code>function videoValidation(videouploadform) {

    var val = $(videouploadform).find(".fileVideo").val();
    switch(val.substring(val.lastIndexOf('.') + 1).toLowerCase()){
        case 'mpg':
        case 'mov': 
        case 'wmv':
        case 'rm':
        case '3g2':
        case '3gp':
        case 'm2v':
        case 'm4v':
             return true;

        case '':
            $(videouploadform).find(".fileVideo").val();
            alert("To upload an video, please select an Video File");
            return false;

        default:
            alert("To upload an video, please select a valild file extension.");
            return false;

    }

    return false;

}
</code></pre>

<p>AUDIO:</p>

<pre><code>  function audioValidation(audiouploadform) {

        var val = $(audiouploadform).find(".fileAudio").val();
        switch(val.substring(val.lastIndexOf('.') + 1).toLowerCase()){
            case 'wav':
            case 'aif': 
            case 'mp3':
            case 'mid':
                 return true;

            case '':
                $(audiouploadform).find(".fileAudio").val();
                alert("To upload an audio, please select an Audio File");
                return false;

            default:
                alert("To upload an audio, please select a valild file extension.");
                return false;

        }

        return false;


}
</code></pre>

<p>Also does anyone know what is the php equivalent on being able to check all image file types, video file types and audio file types as that I will need to do server side validation as well for file types. I just want to know if there is a quicker way than just listing all of the possible image, video and audio file types.</p>
