I'm developing a site that has an image upload section - the code is as follows...

function addPhotog($infoArr, $fileArr){
//strip out everything but the alpha characters in the first and last names...
	$fName = ereg_replace("[^a-z,A-Z,_]","",$infoArr['fname']);
	$lName = ereg_replace("[^a-z,A-Z,_]", "", $infoArr['lname']);
//create the directory name...
	$phoneNumber = preg_replace("/\D/", "", $infoArr['phone']);
	$dir = strtolower(substr($fName, 0, 3).$lName.$phoneNumber);
//	$dir = strtolower(substr($infoArr['fname'], 0, 3).$infoArr['lname'].$phoneNumber);
//insert photographer details into the database...
	$qry="INSERT INTO tblphotogs (fname, lname, eAddy, addr, phone, city, sta, zip, appd, dir, site) VALUES ('".$infoArr['fname']."', '".$infoArr['lname']."', '".$infoArr['eAddy']."', '".$infoArr['addy']."', '".$infoArr['phone']."', '".$infoArr['city']."', '".$infoArr['state']."', '".$infoArr['zip']."', 'no', '$dir', '".$infoArr['site']."');";
//add the photographer info to tblphotog...
	$rs=mysql_query($qry);
	if(!$rs){
		return(false);
		exit;
	}else{
//get the auto_increment number...
		$newID = mysql_insert_id();
//add the specialties and the region to tblphotogdets...
		$specs = insPhotogSpec($newID, $infoArr['rgn'], $infoArr['spec']);
		if(!$specs){
			return(false);
			exit;
		}else{
			$flName = strtolower($fName."_".$lName."_0.jpg");
//			$flName = strtolower($infoArr['fname']."_".$infoArr['lname']."_0.jpg");
			if(!addPhoto($newID, $flName, $dir, $fileArr)){
				return(false);
				exit;
			}
		}
	}
	return(true);
}

function addPhoto($id, $flNm, $dir, $fileArr){
	$imgDir = "../images/$dir";
	if(!is_dir($imgDir)){
		if(!mkdir($imgDir, 0777)){
			return(false);
			exit;
		}
	}
	if(is_uploaded_file($fileArr['tmp_name'])){
		$imgTyp = getimagesize($fileArr['tmp_name']);
		if($imgTyp[2] != 2){
//			print("not a jpeg");
			return(false);
			exit;
		}else{
			if(!move_uploaded_file($fileArr['tmp_name'], "$imgDir/$flNm")){
				return(false);
				exit;
			}else{
				chmod("$imgDir/$flNm", 0666);
				$qry="INSERT INTO tblimgs (nm, photog) VALUES ('$flNm', $id);";
				print(mysql_error());
				$rs=mysql_query($qry);
				if(!$rs){
					return(false);
					exit;
				}
			}
		}
	}
	return(true);
}

This has worked wonders in the past. Suddenly, I'm having a problem. My clients work on Macs - I'm on a PC. I can't see why that should make a difference, but I'm putting it out there just in case. Despite my upload form having a MAX_FILE_SIZE setting of 200000, my client can't upload anything over like 350kb now. I, on the other hand, can upload images of up to 2.32mb just fine.

So, we started comparing. I use Photoshop's Save For Web function when saving my .jpgs. Come to find out he doesn't. So, I tried saving out a flat .jpg using the Save As... command, and it didn't work! My function quoted above will not upload PS jpg's not save with Save For Web on a PC. Because unfortunately, he tried the Save For Web command on his Mac and it didn't work either. Which is wierd, because seriously - this script has been working for weeks and suddenly doesn't anymore. I don't think I changed anything in the code, and can't find where I dumbed it up if I did in fact dumb it up.

Anybody ever come across anything like this before? Ever heard of it? Have any idea what's going on? Or see where I screwed something up? Please?

    Write a Reply...