Hello all,
I have a few functions to upload images and create a thumbnail from that image. Now I am trying to add another function to create a third image that I am calling fullsize – For some reason I cant seem to get it to recognize the third img??
[code=php]
function uploadProductImage($inputName, $uploadDir)
{
$image = $_FILES[$inputName];
$ItemId = (int)$_GET[‘ItemId’];
$imagePath = ”;
$thumbnailPath = ”;
$fullsizePath = ”;
// if a file is given
if (trim($image[‘tmp_name’]) != ”) {
$ext = substr(strrchr($image[‘name’], “.”), 1); //$extensions[$image[‘type’]];
// generate a new file name to avoid name conflict – this is where I want to add ls
$q = “SELECT b.Code FROM item i, brands b WHERE i.ItemId = $ItemId AND i.BrandId = b. BrandId”;
$result = mysql_query($q);
$row = mysql_fetch_assoc($result);
extract($row);
$imagePath = $Code.”-“.$ItemId.”ls” . “.$ext”;
list($width, $height, $type, $attr) = getimagesize($image[‘tmp_name’]);
// make sure the image width does not exceed the
// maximum allowed width
if ($width > 120) {
$result = createThumbnail($image[‘tmp_name’], $uploadDir . $imagePath, 120);
//$fsresult = createFullsize($image[‘tmp_name’], $uploadDir . $imagePath, 350);
$imagePath = $result;
//$fullsizePath = $fsresult;
} else {
$result = move_uploaded_file($image[‘tmp_name’], $uploadDir . $imagePath);
}
if ($result) {
// create thumbnail
$thumbnailPath = $Code.”-“.$ItemId.”tn” . “.$ext”;
$result = createThumbnail($uploadDir . $imagePath, $uploadDir . $thumbnailPath, 96);
// if create thumbnail failed, delete the image
if (!$result) {
unlink($uploadDir . $imagePath);
$imagePath = $thumbnailPath = $fullsizePath = ”;
} else {
$thumbnailPath = $result;
$fullsizePath = $fsresult;
}
} else {
// the product cannot be upload / resized
$imagePath = $thumbnailPath = $fullsizePath = ”;
}
if (!fsresult) {
// create fullsize
$fullsizePath = $Code.”-“.$ItemId.”fs” . “$ext”;
$result = createFullsize($uploadDir . $imagePath, $uploadDir . $fullsizePath, 350);
// if create fullsize failed, delete the image
if (!$result) {
unlink($uploadDir . $imagePath);
$imagePath = $fullsizePath = ”;
} else {
$fullsizePath = $result;
}
} else {
// the product cannot be upload / resized
$imagePath = $thumbnailPath = $fullsizePath = ”;
}
}
return array(‘image’ => $imagePath, ‘thumbnail’ => $thumbnailPath, ‘fullsize’ => $fullsizePath);
}
This sucessfully creates the ImagelsURL and the ImagetnURL – but no ImagefsURL?
any ideas what I am doing wrong?