Jump to content

Upload type


rondog

Recommended Posts

I am working on an upload script and for some reason its saying its the wrong filetype. I want it to only accept jpg or gif, but even if I provide those, it still says incorrect file type:

<?php
	$uploaded_image = $_FILES['imgfield']['name'];
	$type = $_FILES['imgfield']['type'];
	$tmpimg = $_FILES['imgfield']['tmp_name'];
	$name = $_POST['namefield'];
	if(!$name || !$uploaded_image) {
		$error = "<span class=\"error\">Please fill in all fields.</a>";
	} elseif($type != "image/jpeg" || $type != "image/gif") {
		$error = "<span class=\"error\">$type Incorrect file type. Jpg or Gif.</a>";
	} else {
		$width = imagesx($tmpimg);
		$height = imagesy($tmpimg);
		if($width != 150 || $height != 80) {
			$error = "<span class=\"error\">Wrong Image Size. Must be 150x80.</a>";
		} else {
			$success = "<span class=\"success\">Successfully added.</a>";
		}
	}		
}
?>

 

and if I echo $type it says image/jpeg or image/gif depending on what I upload.

Link to comment
https://forums.phpfreaks.com/topic/104503-upload-type/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.