/    Sign up×
Community /Pin to ProfileBookmark

help upload and create img’s

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);
}[/code]

This sucessfully creates the ImagelsURL and the ImagetnURL – but no ImagefsURL?
any ideas what I am doing wrong?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @samoht spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...