File validation via Regular Expresion - Javascript
<p>I'm using an upload plugin to upload files in jquery.</p>

<p>This gets the type of the file uploaded (e.g. jpeg):</p>

<pre><code>data.files[0].type
</code></pre>

<p>I need to check if it's a valid image file type (usal image file types jpeg, jpeg, gif, png) using a reg expression.</p>

<p>So far I have:</p>

<pre><code>var isValid = (/\.(gif|jpg|jpeg|tiff|png)$/i).test(data.files[0].type);
</code></pre>

<p>But it's not working (always returns false).</p>

<p>Any ideas on how to fix?</p>

<p>Thanks</p>
