: : I have this code block to restrict files uploaded to just images.
: :
: : if (($_FILES['upload']['type'] != 'image/gif')
: : || ($_FILES['upload']['type'] != 'image/jpeg')
: : || ($_FILES['upload']['type'] != 'image/jpg')
: : || ($_FILES['upload']['type'] != 'image/bmp')
: : || ($_FILES['upload']['type'] != 'image/png') )
: : {
: : echo($_FILES['upload']['type']);
: : die("Not right file formatt. gif, jpeg, jpg,bmp, and png only");
: : }
: :
: : But when I test it, I get the die message, even though I know my
: : file type is correct. I even echo out the $_FILES['upload']['type']
: :
: : and I get image/jpeg
: :
: : Any ideas on what is wrong with my code?
: :
: :
:
:
: Ur code has a LOGICAL error. U should not use an or ||, use && (and)
: operator to join the expressions
:
: ie
:
:
: if (($_FILES['upload']['type'] != 'image/gif')
: && ($_FILES['upload']['type'] != 'image/jpeg')
: && ($_FILES['upload']['type'] != 'image/jpg')
: && ($_FILES['upload']['type'] != 'image/bmp')
: && ($_FILES['upload']['type'] != 'image/png')
:
:
:
: Think over it, u will understand why :)
:
I think I understand. That's what I get for simply cutting and pasting code directly from the Internet. Sometimes I feel as if I odnt really program, I just assemble (no pun on the assembly language intended) code together from the Internet and past projects using cut (cntr c) and paste (cntr v)