garydt Posted June 18, 2007 Share Posted June 18, 2007 When the user uploads an image the script checks to see if its a jpeg. If it isn't it will redirect to another page but its redirecting regardless of the image being a jpeg or not. $chktype = $_FILES['file']['type']; if ($chktype!='jpeg' or $chktype!='JPEG') { header("Location: regform2.php"); exit; } Quote Link to comment https://forums.phpfreaks.com/topic/56022-being-redirected-everytime/ Share on other sites More sharing options...
chocopi Posted June 18, 2007 Share Posted June 18, 2007 echo the chktype to see what its giving Quote Link to comment https://forums.phpfreaks.com/topic/56022-being-redirected-everytime/#findComment-276684 Share on other sites More sharing options...
garydt Posted June 18, 2007 Author Share Posted June 18, 2007 $chktype is givng image/pjpeg is that right? Quote Link to comment https://forums.phpfreaks.com/topic/56022-being-redirected-everytime/#findComment-276690 Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 You can also use the function getimagesize() Example: list($width, $height, $type, $attr) = getimagesize($_FILES["file_image"]["tmp_name"]); Then check whether the $type == 2 or Not . If it is 2 the image is JPG or JPEG. More details : http://www-eleves-isia.cma.fr/documentation/PhpDoc/function.getimagesize.html Quote Link to comment https://forums.phpfreaks.com/topic/56022-being-redirected-everytime/#findComment-276691 Share on other sites More sharing options...
chocopi Posted June 18, 2007 Share Posted June 18, 2007 i dont think that is right seeing as image/pjpeg does not equal JPEG or jpeg <?php $text1 = "image/pjpeg"; $text2 = "JPEG"; $text3 = "jpeg"; if($text1 != $text2 or $text != $text3) { //redirect } else { // your stuff } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56022-being-redirected-everytime/#findComment-276697 Share on other sites More sharing options...
garydt Posted June 18, 2007 Author Share Posted June 18, 2007 Thanks i put- $fieldname = $_FILES['file']; list($width, $height, $type, $attr) = getimagesize($fieldname); and i get- Notice: Array to string conversion in C:\Program Files\xampp\htdocs\epeople\editphoto.php on line 42 Warning: getimagesize(Array) [function.getimagesize]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\epeople\editphoto.php on line 42 Quote Link to comment https://forums.phpfreaks.com/topic/56022-being-redirected-everytime/#findComment-276717 Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 I think, there is an error in your code for checking the Image name.. Please go through the site and understand the file uploading. Please go through this lines of code. here "file_image" is the name of the image field. if($_FILES["file_image"]["name"]) { $arr = getimagesize($_FILES["file_image"]["tmp_name"]); list($width, $height, $type, $attr) = getimagesize($_FILES["file_image"]["tmp_name"]); if($type == FALSE) { header("Location:test.php?status=This is not an Image"); exit(); } elseif($type != 2) { header("Location:test.php?status=This is not an JPG or JPEG Image"); exit(); } } Quote Link to comment https://forums.phpfreaks.com/topic/56022-being-redirected-everytime/#findComment-276723 Share on other sites More sharing options...
garydt Posted June 18, 2007 Author Share Posted June 18, 2007 Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/56022-being-redirected-everytime/#findComment-276748 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.