Smart Image Processor PHP 2 Support Product Page

Issues when adding file names to database

Asked 07 Aug 2010 13:12:38
1
has this question
07 Aug 2010 13:12:38 Celeste Pretzel posted:
<p>Works fine for uploading only. I have it resizing and uploading original, as well as creating a thumbnail.<br /></p><p>however, when i attempt to insert a record to the mysql database, the thumbnail does not get created.</p><p>the original sip work for me a one point, but now both versions are not working.</p><p>i'm on win7pro/cs4. (tried sip1 on dreamweaver 8 since it's not supported on cs4)</p><p>i hope this purchase wasn't in vain and support can get me through it, otherwise i'm out a lot of cash. hope they have a return policy. <br /></p>

Replies

Replied 07 Aug 2010 22:16:25
07 Aug 2010 22:16:25 Celeste Pretzel replied:
I found that the form action is overwritten when you add the insert record. when i changed it back to ...
action=<?php echo $GP_uploadAction; ?>

... it starts to work again.

in the sip thumbnail creation part. i checked resize and crop (center). it does not crop. it just resizes.
Replied 07 Aug 2010 22:18:33
07 Aug 2010 22:18:33 Celeste Pretzel replied:
okay the resize and crop will work IF:
the resize dimensions are set slightly larger to the crop dimensions.

Here's all my code that finally worked.



<?php require_once('../ScriptLibrary/incPureUpload.php'); ?>
<?php require_once('../ScriptLibrary/cGraphicMediator.php'); ?>
<?php require_once('../Connections/wassenaar_db.php'); ?>
<?php
// Pure PHP Upload 2.1.10
$ppu = new pureFileUpload();
$ppu->path = "../imgs/gall_lg";
$ppu->extensions = "GIF,JPG,JPEG,BMP,PNG";
$ppu->formName = "uploadImage";
$ppu->storeType = "file";
$ppu->sizeLimit = "4000";
$ppu->nameConflict = "uniq";
$ppu->requireUpload = "true";
$ppu->minWidth = "";
$ppu->minHeight = "";
$ppu->maxWidth = "";
$ppu->maxHeight = "";
$ppu->saveWidth = "";
$ppu->saveHeight = "";
$ppu->timeout = "600";
$ppu->progressBar = "";
$ppu->progressWidth = "";
$ppu->progressHeight = "";
$ppu->redirectURL = "";
$ppu->checkVersion("2.1.10");
$ppu->doUpload();
?>
<?php
// Smart Image Processor PHP 2.0.7
if (isset($_GET['GP_upload'])) {
$sipp2 = new cGraphicMediator("upload", $ppu, "file_name");
$sipp2->setComponent("Auto");
$sipp2->setMatteColor("#FFFFFF");
$sipp2->resize(600, 600, true);
$sipp2->overwrite = true;
$sipp2->saveJPEG(100);
$sipp2->process();
}
?>
<?php
// Smart Image Processor PHP 2.0.7
if (isset($_GET['GP_upload'])) {
$sipp1 = new cGraphicMediator("upload", $ppu, "");
$sipp1->setComponent("Auto");
$sipp1->setMatteColor("#FFFFFF");
$sipp1->resize(120, 120, true);
$sipp1->cropPos("Center-Center", 99, 99);
$sipp1->overwrite = false;
$sipp1->setMask("##path##thumb_##name##.jpg");
$sipp1->saveJPEG(80);
$sipp1->process();
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
if (isset($editFormAction)) {
  if (isset($_SERVER['QUERY_STRING'])) {
	  if (!eregi("GP_upload=true", $_SERVER['QUERY_STRING'])) {
  	  $editFormAction .= "&GP_upload=true";
		}
  } else {
    $editFormAction .= "?GP_upload=true";
  }
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "uploadImage")) {
  $insertSQL = sprintf("INSERT INTO galleries_data (file_name, file_galleries_id, file_desc) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['file_name'], "text"),
                       GetSQLValueString($_POST['file_galleries_id'], "int"),
                       GetSQLValueString($_POST['file_desc'], "text"));

  mysql_select_db($database_wassenaar_db, $wassenaar_db);
  $Result1 = mysql_query($insertSQL, $wassenaar_db) or die(mysql_error());
}

$colname_Recordset1 = "-1";
if (isset($_GET['gallery_id'])) {
  $colname_Recordset1 = $_GET['gallery_id'];
}
mysql_select_db($database_wassenaar_db, $wassenaar_db);
$query_Recordset1 = sprintf("SELECT * FROM galleries WHERE gallery_id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $wassenaar_db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="admin.css" rel="stylesheet" type="text/css" />
<script language='JavaScript' src='../ScriptLibrary/incPureUpload.js' type="text/javascript"></script>
</head>

<body>

<div id="container">
  <div id="mainContent">
    <p><?php echo $row_Recordset1['gallery_name']; ?></p>
    <p>&nbsp;</p>
    <form action="<?php echo $GP_uploadAction; ?>" method="POST" enctype="multipart/form-data" name="uploadImage" id="uploadImage" onsubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,4000,'','','','','','');return document.MM_returnValue">
      <p>Photo
        <br />
        <input name="file_name" type="file" id="file_name" onchange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,4000,'','','','','','')" />
      </p>
      <p>Photo Description<br />
<textarea name="file_desc" id="file_desc" cols="45" rows="5"></textarea>
      </p>
      <p>
        <input type="submit" name="button" id="button" value="Submit" />
        <input name="file_galleries_id" type="hidden" id="file_gallery_id" value="<?php echo $row_Recordset1['gallery_id']; ?>" />
      </p>
      <input type="hidden" name="MM_insert" value="uploadImage" />
    </form>
	<!-- end #mainContent --></div>
  <!-- end #container -->
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

Reply to this topic