php - preg match on image -


i wondering, have project in person copies link form. link has image , of use guys never trust user input.

i narrowed down preg_match() can check there image on link can displayed on site.

my question how make sure when checking form, image , not virus .jpg @ end of extension.

$url = 'http://foo.bar.com/path.jpg?arg=value#anchor'; if (preg_match("/\.(jpg|png)$/",parse_url($url, php_url_path)){     // code here } 

this matches filename ends .jpg or .png.... add in parentheses extensions want allow (separated | symbol)


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -