Jump to content

[SOLVED] upload picture script problem. uploads jpg (lowercase) but not JPG (uppercase)


coolphpdude

Recommended Posts

upload picture script problem. uploads jpg (lowercase) but not JPG (uppercase). Why??

 

im having a problem with my script and i have only just figured out what is causing it but i don't know what to do to fix it! Any files that have got uppercase file extensions are getting rejected on upload as invalid file type, any ideas why???

 

i will post my code that i think it is in connection with.

 

//SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
switch($image_type) {
	case '.jpg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.jpeg':
		$img_src = imagecreatefromjpeg($sourcefile);
		break;
	case '.png':
		$img_src = imagecreatefrompng($sourcefile);
		break;
	case '.gif':
		$img_src = imagecreatefromgif($sourcefile);
		break;
	default:
		echo("Error Invalid Image Type");
		die;
		break;
}


		if ((($_FILES["pic"]["type"] == "image/pjpeg")
		|| ($_FILES["pic"]["type"] == "image/jpeg")
		|| ($_FILES["pic"]["type"] == "image/JPEG")
		|| ($_FILES["pic"]["type"] == "image/png")
		|| ($_FILES["pic"]["type"] == "image/bmp"))
		&& ($_FILES["pic"]["size"] < 4000000))

 

any idea???

do this:

 

$tem_it = strtolower($image_type);
switch($tem_it) {
case '.jpg':
	$img_src = imagecreatefromjpeg($sourcefile);
break;
case '.jpeg':
	$img_src = imagecreatefromjpeg($sourcefile);
break;
case '.png':
	$img_src = imagecreatefrompng($sourcefile);
	break;
case '.gif':
	$img_src = imagecreatefromgif($sourcefile);
	break;
default:
	echo("Error Invalid Image Type");
	die;
	break;
}

yeah tell me about it, at first I thought it was the original file size or original picture resolution but after playing about with it on photoshop i realised that it was the extension that was causing the problem. Both exactly the same file type just one uppercase and one lowercase, tested this thoroughly and for some reason it just refuses to upload uppercase file extensions.

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.