Warning: imagesx(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1769
Warning: imagesy(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1769
Warning: imagesx(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1778
Warning: imagesy(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1779
Warning: imagecreatetruecolor(): Invalid image dimensions in /home/soderbrg/public_html/admin.php on line 1782
Warning: imagesx(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1783
Warning: imagesy(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1783
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1783
Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1785
Warning: imagesx(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1791
Warning: imagesy(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1791
Warning: imagesx(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1800
Warning: imagesy(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1801
Warning: imagecreatetruecolor(): Invalid image dimensions in /home/soderbrg/public_html/admin.php on line 1804
Warning: imagesx(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1805
Warning: imagesy(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1805
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1805
Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/soderbrg/public_html/admin.php on line 1806
Code: Select all
if ($action=='uploadimg') {
if (session_is_registered("uid")) {
$prod_id=$_GET['prod_id'];
$filename = $_FILES['imagefile']['name'];
$temporary_name = $_FILES['imagefile']['tmp_name'];
$mimetype = $_FILES['imagefile']['type'];
$filesize = $_FILES['imagefile']['size'];
$split = explode(".", $filename);
$name=$split[0];
switch($mimetype) {
case "image/jpg":
case "image/jpeg":
$i = imagecreatefromjpeg($temporary_name);
break;
case "image/gif":
$i = imagecreatefromgif($temporary_name);
break;
case "image/png":
$i = imagecreatefrompng($temporary_name);
break;
}
unlink($temporary_name);
//imagejpeg($i,"images/uploadedfile.jpg",80);
//Specify the size of the new product image
$dest_x = 200;
$dest_y = 300;
if (imagesx($i) > $dest_x or imagesy($i) > $dest_y) {
if (imagesx($i) >= imagesy($i)) {
$thumb_x = $dest_x;
$thumb_y = imagesy($i)*($dest_x/imagesx($i));
} else {
$thumb_x = imagesx($i)*($dest_y/imagesy($i));
$thumb_y = $dest_y;
}
} else {
$thumb_x = imagesx($i);
$thumb_y = imagesy($i);
}
$thumb = imagecreatetruecolor($thumb_x,$thumb_y);
imagecopyresampled($thumb, $i ,0, 0, 0, 0, $thumb_x, $thumb_y, imagesx($i), imagesy($i));
//Save the product image
imagejpeg($thumb, "images/".$name.".jpg", 80);
//Creating the thumbnail image
$dest_x = 75;
$dest_y = 75;
if (imagesx($i) > $dest_x or imagesy($i) > $dest_y) {
if (imagesx($i) >= imagesy($i)) {
$thumb_x = $dest_x;
$thumb_y = imagesy($i)*($dest_x/imagesx($i));
} else {
$thumb_x = imagesx($i)*($dest_y/imagesy($i));
$thumb_y = $dest_y;
}
} else {
$thumb_x = imagesx($i);
$thumb_y = imagesy($i);
}
$thumb = imagecreatetruecolor($thumb_x,$thumb_y);
imagecopyresampled($thumb, $i ,0, 0, 0, 0, $thumb_x, $thumb_y, imagesx($i), imagesy($i));
imagejpeg($thumb, "images/".$name."_th.jpg", 80);
$sql="update product_pages set prod_image='$filename', prod_image_th='".$name."_th.jpg' where prod_id='".$prod_id."'";
$result = mysql_query($sql);
?>
<tr>
<td class="text" width="100%" align="center">The Image : <b><?=$filename?></b> has been added for the Product.</td>
</tr>
<tr>
<td class='text' align='center'><a href="admin.php?action=uploadfile&prod_id=<?=$prod_id?>" class="link">Click here to Upload a Document</a> | <a href="admin.php?action=admin" class="link">Admin Main Page</a></td>
</tr>
<?
} else {
?>
<script LANGUAGE="JavaScript">
<!--
location='admin.php?action=login ';
// -->
</script>
<?
}
}