shadiadiph Posted May 15, 2009 Share Posted May 15, 2009 ho do i make it so that the file type atached is onl;y image type gif png jpg jpeg gif bmp??? Link to comment https://forums.phpfreaks.com/topic/158205-solved-uploading-only-images/ Share on other sites More sharing options...
justAnoob Posted May 15, 2009 Share Posted May 15, 2009 This is just the extensio part of what I have.... If you can't figure out the rest,,, post your code that you have for your upload script. This will only allow .jpg ,,, you can add others. <?php $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg")) { Have your error here. } Just so you know,, this is far from secure from what I have heard. How,, I don't know.. Still learning myself Link to comment https://forums.phpfreaks.com/topic/158205-solved-uploading-only-images/#findComment-834486 Share on other sites More sharing options...
shadiadiph Posted May 15, 2009 Author Share Posted May 15, 2009 thanks i'll give it a go i dont suppose you know the correct alternative extensions if thee are any for bmp gif or png? i noticed in your script you missed out pjpeg Link to comment https://forums.phpfreaks.com/topic/158205-solved-uploading-only-images/#findComment-834490 Share on other sites More sharing options...
justAnoob Posted May 15, 2009 Share Posted May 15, 2009 you can add "pjpeg" if you want. the four that I allow to upload are jpg jpeg png bmp Link to comment https://forums.phpfreaks.com/topic/158205-solved-uploading-only-images/#findComment-834495 Share on other sites More sharing options...
ldougherty Posted May 15, 2009 Share Posted May 15, 2009 Another option is to use the getimagesize function to validate if the file uploaded is indeed an image... // validation... since this is an image upload script we should run a check // to make sure the uploaded file is in fact an image. Here is a simple check: // getimagesize() returns false if the file tested is not an image. @getimagesize($_FILES[$fieldname]['tmp_name']) Link to comment https://forums.phpfreaks.com/topic/158205-solved-uploading-only-images/#findComment-834515 Share on other sites More sharing options...
shadiadiph Posted May 16, 2009 Author Share Posted May 16, 2009 thank you Link to comment https://forums.phpfreaks.com/topic/158205-solved-uploading-only-images/#findComment-835151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.