Bman900 Posted July 4, 2010 Share Posted July 4, 2010 I want users to be able to choose an image as an avatar but I want to make sure its an image and not something else entering my database. Quote Link to comment https://forums.phpfreaks.com/topic/206673-checking-end-of-url-to-make-sure-its-an-image/ Share on other sites More sharing options...
sKunKbad Posted July 4, 2010 Share Posted July 4, 2010 Most file upload tutorials will cover how to check the uploaded file to determine if it is evil. Quote Link to comment https://forums.phpfreaks.com/topic/206673-checking-end-of-url-to-make-sure-its-an-image/#findComment-1080899 Share on other sites More sharing options...
dreamwest Posted July 4, 2010 Share Posted July 4, 2010 if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/pjpeg"))){ echo " Image Type: " . $_FILES["file"]["type"] . "<br />"; } Quote Link to comment https://forums.phpfreaks.com/topic/206673-checking-end-of-url-to-make-sure-its-an-image/#findComment-1080903 Share on other sites More sharing options...
Bman900 Posted July 4, 2010 Author Share Posted July 4, 2010 Am not actually uploading am letting the user submit a url of on image and I want to make sure it really is am image by checking the end of the URL he submits that it ends with .jpeg, .png and so on. Quote Link to comment https://forums.phpfreaks.com/topic/206673-checking-end-of-url-to-make-sure-its-an-image/#findComment-1080907 Share on other sites More sharing options...
dreamwest Posted July 4, 2010 Share Posted July 4, 2010 strrchr($img, '.'); Will return the end of the string after the "." Quote Link to comment https://forums.phpfreaks.com/topic/206673-checking-end-of-url-to-make-sure-its-an-image/#findComment-1080912 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.