Smart Image Processor PHP 2 Support Product Page

Answered

Using Path to write thumnails to sub directory

Asked 05 Jul 2012 03:12:17
1
has this question
05 Jul 2012 03:12:17 Chuck Borrelli posted:
I am trying to get the thumbnail of the image to appear in the sub directory of the main image.

The main image is being uploaded to "dbgallery", but the thumnail is not being saved to
"dbgallery/thumbs"

by default, the path for the thumnail is

##path##thumb_##name##.jpg

Which will load it into the same directory, with a "thumb" prefix.

I would like to have it with the SAME name, but in a different directory.

I have tried

"##path##/thumbs/##name##.jpg"
"dbgallery/thumbs/##name##.jpg"
"##path/thumbs##/##name##.jpg"

Nothing worked.

Any suggestions? There is nothing I could see in you manual about how to have the thumbnail appear in a different directory...

Replies

Replied 05 Jul 2012 07:19:24
05 Jul 2012 07:19:24 Teodor Kuduschiev replied:
Hello,

Please check the following article: www.dmxzone.com/go?16935
Replied 05 Jul 2012 09:44:39
05 Jul 2012 09:44:39 Chuck Borrelli replied:
This is not working... I did try this. See code below... the original image is being uploaded, but not the thumbnail...

permissions on the upload directory is correct.


<?php require_once('ScriptLibrary/incPureUpload.php'); ?>
<?php require_once('ScriptLibrary/cGraphicMediator.php'); ?>
<?php
// Pure PHP Upload 2.1.12
$ppu = new pureFileUpload();
$ppu->path = "dbgallery";
$ppu->extensions = "JPG,JPEG,PNG";
$ppu->formName = "addPhoto";
$ppu->storeType = "file";
$ppu->sizeLimit = "2000";
$ppu->nameConflict = "over";
$ppu->nameToLower = true;
$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.12");
$ppu->doUpload();

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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

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"] == "addPhoto")) {
  $insertSQL = sprintf("INSERT INTO PhotoGallery (photoSrc, photoTitle, photoCaption, sortOrder, isActive) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['photoSrc'], "text"),
                       GetSQLValueString($_POST['photoTitle'], "text"),
                       GetSQLValueString($_POST['photoCaption'], "text"),
                       GetSQLValueString($_POST['sortOrder'], "int"),
                       GetSQLValueString(isset($_POST['isActive']) ? "true" : "", "defined","'Y'","'N'"));

  mysql_select_db($database_elite, $elite);
  $Result1 = mysql_query($insertSQL, $elite) or die(mysql_error());

  $insertGoTo = "managephotos.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php
// Smart Image Processor PHP 2.0.9
if (isset($_GET['GP_upload'])) {
$sipp2 = new cGraphicMediator("upload", $ppu, "photoSrc");
$sipp2->setComponent("Auto");
$sipp2->setMatteColor("#FFFFFF");
$sipp2->resizeEx(700, 466, true, false);
$sipp2->overwrite = true;
$sipp2->saveJPEG(80);
$sipp2->process();
}
?>
<?php
// Smart Image Processor PHP 2.0.9
if (isset($_GET['GP_upload'])) {
$sippthumb = new cGraphicMediator("upload", $ppu, "photoSrc");
$sippthumb->setComponent("Auto");
$sippthumb->setMatteColor("#FFFFFF");
$sippthumb->resizeEx(90, 90, true, false);
$sippthumb->overwrite = false;
$sippthumb->setMask("##path##/thumbs/##name##.jpg");
$sippthumb->saveJPEG(80);
$sippthumb->process();
}
?>
Replied 05 Jul 2012 09:54:33
05 Jul 2012 09:54:33 Teodor Kuduschiev replied:
I just tested this - everything works fine. Is your thumbs folder created? Please also check the permissions once again.
Replied 05 Jul 2012 13:59:54
05 Jul 2012 13:59:54 Chuck Borrelli replied:
Yes, the thumbs folder is created, and permissions are the same as the dbgallery folder... which is 777

However, whenever I upload an image, nothing gets uploaded to the thumbs directory.


As is typical with your products... they work 90%, and getting it to work flawlessly is always a problem.

Anyway, I tried writing to the same directory by chaninging the setMask to:

$sippthumb->setMask("##path##/tn_##name##.jpg";

and the image was not uploaded. so it is not a permissions issue... it is a coding issue

Reply to this topic