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??? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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']) Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted May 16, 2009 Author Share Posted May 16, 2009 thank you Quote Link to comment 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.