Jump to content

Recommended Posts

It is uploading everything except .jpgs and .jpeg. can somone help me figure this out?

this is the code for the upload image form

if(is_array($_FILES['imageName'])){
	$date_str=date('Ymdhis');
	$imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName']['name']));
if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){
	copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name']));
		$record["image"] = $db->mySQLSafe($date_str."_".$_FILES['imageName']['name']);
	copy($_FILES['imageName']['tmp_name'],"images/uploads/thumbs/thumb_".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name']));
	if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'])){
		@chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'], 0775);
		unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name']);
	}

	$thumb=new thumbnail("images/uploads/".$date_str."_".$_FILES['imageName']['name']);
if(is_array($_FILES['imageName'])){
	$date_str=date('Ymdhis');
	$imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName']['name']));
if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){
	copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name']));
		$record["image"] = $db->mySQLSafe($date_str."_".$_FILES['imageName']['name']);
	copy($_FILES['imageName']['tmp_name'],"images/uploads/thumbs/thumb_".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name']));
	if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'])){
		@chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'], 0775);
		unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name']);
	}

	$thumb=new thumbnail("images/uploads/".$date_str."_".$_FILES['imageName']['name']);
	// see if we need to resize 
	if(($size[0] > $config['gdthumbSize']) OR ($size[1] > $config['gdthumbSize'])){
		$thumb->size_auto($config['gdthumbSize']);
	} else {
		$thumb->size_auto($size[0]);
	}
	$thumb->jpeg_quality($config['gdquality']);
	$thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']);
	}
}
	$imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_POST['imageName']));
if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){

	if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'])){
		@chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'], 0775);
		unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']);
	}

	$thumb=new thumbnail($GLOBALS['rootDir']."/images/uploads/".$_POST['imageName']);
	$thumb->size_auto($config['gdthumbSize']);
	$thumb->jpeg_quality($config['gdquality']);
	$thumb->save($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']);
}
	$music_upload->assign("VAL_IMAGE_UP",$lang['admin']['products']['upload_new']);
if(isset($results[0]['image'])){
	$music_upload->assign("VAL_IMAGE",$results[0]['image']); 
}

Link to comment
https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/
Share on other sites

Why is that first chunk of code:

if(is_array($_FILES['imageName'])){
	$date_str=date('Ymdhis');
	$imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName']['name']));
if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){
	copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name']));
		$record["image"] = $db->mySQLSafe($date_str."_".$_FILES['imageName']['name']);
	copy($_FILES['imageName']['tmp_name'],"images/uploads/thumbs/thumb_".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name']));
	if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'])){
		@chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'], 0775);
		unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name']);
	}

	$thumb=new thumbnail("images/uploads/".$date_str."_".$_FILES['imageName']['name']);

in there twice?

 

Try changing this:

$thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']);

 

to:

$thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']) or die("save error");

 

and see if it is the save function that is failing.

Link to comment
https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333148
Share on other sites

it loaded a blank page with the errors i am receiving because it isnt uploading so my gd can not find the file.

 

(that was after i put that line of text in there)

 

the reason for the first and second part of the code looking simalar is because i created the first code and the second code was already on there should i remove the second code?

 

 

theirs a ton of problems in that script!..

do PNG files work!?

 

Yes they do

Link to comment
https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-333156
Share on other sites

So there is a save error that i dont understand.

$thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']) or die("save error");		}

The code in its entirety:

if(is_array($_FILES['imageName'])){
	$date_str=date('Ymdhis');
	$imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['imageName']['name']));
if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){
	copy($_FILES['imageName']['tmp_name'],"images/uploads/".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])) or die("| copy error |");
		$record["image"] = $db->mySQLSafe($date_str."_".$_FILES['imageName']['name']);
	copy($_FILES['imageName']['tmp_name'],"images/uploads/thumbs/thumb_".$date_str."_".str_replace(' ','_',$_FILES['imageName']['name'])) or die("| copy 2 Thumb error |");
	if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'])){
		@chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name'], 0775);
		unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_FILES['imageName']['name']);
	}

	$thumb=new thumbnail("images/uploads/".$date_str."_".$_FILES['imageName']['name']);
	// see if we need to resize 
	if(($size[0] > $config['gdthumbSize']) OR ($size[1] > $config['gdthumbSize'])){
		$thumb->size_auto($config['gdthumbSize']);
	} else {
		$thumb->size_auto($size[0]);
	}
	$thumb->jpeg_quality($config['gdquality']);
$thumb->save("images/uploads/thumbs/thumb_".$date_str.$_FILES['imageName']['name']) or die("save error");		}
}

Link to comment
https://forums.phpfreaks.com/topic/66522-jpg-upload-prob/#findComment-337945
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.