Jump to content

how do i


ccrevcypsys

Recommended Posts

Well here is the scenerio i am trying to make albums for all of my customers images. Everything works but posting the album_id to the images db. Here is the table set up

---Images---    ---Images_albums---

id (auto_inc)  +----album_id(auto_inc)

title                    customer_id

image                  albumName

customer_id

album_id  ----+

 

And here is my code for the page:

$record["title"] = $db->mySQLSafe($_POST['title']);
$record["desc"] = $db->mySQLSafe($_POST['desc']);
$record["default"] = $db->mySQLSafe($_POST['default']);
$record["visible"] = $db->mySQLSafe($_POST['visible']);
$record["customer_id"]=$ccUserData[0]['customer_id'];

$date_str=date('Ymdhis');
$uploadFileName = str_replace(array(" ","%20"),"_",$_FILES['image']['name']);
if(isset($_GET["edit"])==TRUE){ 
		echo "Image Stays The Same";
	}else{
if($_FILES['image']['size'] > $config['maxImageUploadSize']) { 

$imgmsg = "<p class='image-fail'>".$lang['admin']['filemanager']['file_too_big']." ".$uploadFileName." ".format_size($config['maxImageUploadSize'])."</p>"; 
unlink($_FILES['image']['tmp_name']);

} elseif (file_exists($GLOBALS['rootDir']."/images/uploads/customer_images/".$date_str."_".$uploadFileName)) {

 $imgmsg = "<p class='image-fail'>".$lang['admin']['filemanager']['img_already_exists']." ".$uploadFileName."</p>";

} elseif (!is_uploaded_file($_FILES['image']['tmp_name'])) { 

$imgmsg = "<p class='image-fail'>".$lang['admin']['filemanager']['upload_too_large']."</p>";

} elseif ($_FILES['image']['type'] != "image/jpeg" AND $_FILES['image']['type'] != "image/png"  AND $_FILES['image']['type'] != "image/x-png" AND $_FILES['image']['type'] != "image/pjpeg" AND $_FILES['image']['type'] != "image/x-jpeg" AND $_FILES['image']['type'] != "image/gif"){
$imgmsg = "<p class='image-fail'>".$lang['admin']['filemanager']['not_valid_mime']." ".$uploadFileName."</p>";
unlink($_FILES['image']['tmp_name']); 
} else {

if (is_uploaded_file($_FILES['image']['tmp_name'])) {
	$savefile = $GLOBALS['rootDir']."/images/uploads/customer_images/".$date_str."_".$uploadFileName;

if (move_uploaded_file($_FILES['image']['tmp_name'], $savefile)) {
	@chmod($savefile, 0644);
	// if image is a JPG check thumbnail doesn't exist and if not make one
$imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$uploadFileName));

if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){


	// check image is not too big
	$size = getimagesize($savefile);

	if(($size[0] > $config['gdmaxImgSize']) OR ($size[1] > $config['gdmaxImgSize'])){

	@chmod($savefile, 0775);

	$thumb=new thumbnail($savefile);
	$thumb->size_auto($config['gdmaxImgSize']);
	$thumb->jpeg_quality($config['gdquality']);
	$thumb->save($savefile);

	}


	if(file_exists("images/uploads/customer_images/thumbs/thumb_".$date_str."_".$uploadFileName)){
		@chmod("images/uploads/customer_images/thumbs/thumb_".$date_str."_".$uploadFileName, 0775);
		unlink("images/uploads/customer_images/thumbs/thumb_".$date_str."_".$uploadFileName);}

	$thumb=new thumbnail("images/uploads/customer_images/".$date_str."_".$uploadFileName);
	// 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/customer_images/thumbs/thumb_".$date_str."_".$uploadFileName);
	$record["image"] = $db->mySQLSafe($date_str."_".$uploadFileName);
}
		$imgmsg = "<p class='image-fail'>".$lang['admin']['filemanager']['image_upload_success']." ".$uploadFileName."</p>";
		 // end if not set redir
	}
}

}	
} 
if($_POST['title']){
  if($ccUserData[0]['customer_id']>0){
if(empty($_POST['albumName'])){
  $albumRecord["albumName"] = $db->mySQLSafe($_POST['albumName_select']);
  }else{
  $albumRecord["albumName"] = $db->mySQLSafe($_POST['albumName']);
  }
  $albumRecord["customer_id"] = $db->mySQLSafe($ccUserData[0]['customer_id']);
  $insert = $db->insert($glob['dbprefix']."StreamRush_Images_albums", $albumRecord);
	if($insert==TRUE){
  $record["album_id"] = $db->mySQLSafe($id['album_id']);
	$insert = $db->insert($glob['dbprefix']."StreamRush_Images", $record);
	}
		if($insert==TRUE){
		$viewImages->assign("Success", "Created and uploaded your picture");
		}else{
		$viewImages->assign("Success", "Creation Failed make sure you have all of the fields filled in.");
		}}
	}

what is the best way to do this... i am confused

Link to comment
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.