Check whether remote URL has a valid image extension
<p>How can I check that a remote URL has a valid image extension?</p>

<p>What I want to do is upload images via link using PHP</p>

<pre><code>copy('http://website.com/image.jpg', '/upload/filename.jpeg');
</code></pre>

<p>Code works fine but i want to check whether entered url has a valid image extension.</p>

<p>It should be jpg, png or gif file. Love to see a example of how to do this.</p>

<p>Your help and time is highly appreciated. </p>