I have a code to upload an image, crop it and make a thumbnail version...the problem is the code does not seem to work in INTERNET EXPLORER....it seems to work well with other browsers and also sometimes it makes the the thumbs and other times, it does not. What did I do wrong? Please help!!!!!!
FOR THE THUMBNAIL:
function create_thumb($image_type,$file_old,$file_new)
{
$max_size = 200;
@list($width, $height) = getimagesize($file_old);
if($width <= $max_size && $height <= $max_size){
copy($file_old, $file_new);
} else {
if ($width > $height) {
$src_w = $src_h = $height;
$src_y = 0;
$src_x = round(($width - $height) / 2);
} else {
$src_w = $src_h = $width;
$src_x = 0;
$src_y = round(($height - $width) / 2);
}
$temp_image = imagecreatetruecolor(200, 150);
switch($image_type){
case 'png':
$image = imagecreatefrompng($file_old);
imagecopyresampled($temp_image, $image, 0, 0, $src_x, $src_y, $max_size, $max_size, $src_w, $src_h);
imagepng($temp_image, $file_new);
break;
case 'jpg':
$image = imagecreatefromjpeg($file_old);
imagecopyresampled($temp_image, $image, 0, 0, $src_x, $src_y, $max_size, $max_size, $src_w, $src_h);
imagejpeg($temp_image, $file_new);
break;
case 'gif':
$image = imagecreatefromgif($file_old);
imagecopyresampled($temp_image, $image, 0, 0, $src_x, $src_y, $max_size, $max_size, $src_w, $src_h);
imagegif($temp_image, $file_new);
break;
}
}
}
UPLOADING THE IMAGE:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "photos"))
{
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
$ext = findexts ($_FILES['photo1']['name']);
$ran = rand () ;
$ran2 = $ran.".";
$target = "/IMAGES/Albums/";
$targetb = $target . $ran2.$ext;
//Upload thumbs
$target_thumb = "/IMAGES/Albums/Thumbs/";
$target_thumbb = $target_thumb . $ran2.$ext;
$pic = $ran2.$ext;
{
if($_FILES["photo1"]["type"] == "image/gif"){
$resize_type3 = 'gif';
}
if($_FILES["photo1"]["type"] == "image/jpeg"){
$resize_type3 = 'jpg';
}
if($_FILES["photo1"]["type"] == "image/png"){
$resize_type3 = 'png';
}
$pictno = mt_rand () ;
$pictID = $pictno;
//Writes the photo to the server
if (move_uploaded_file($_FILES['photo1']['tmp_name'], $targetb))
{
create_thumb($resize_type3,$targetb,$target_thumbb);
$insertSQL = sprintf("INSERT INTO Picts (Image, ImageID, Certify) VALUES (%s, %s, %s)",
GetSQLValueString($pic, "text"),
GetSQLValueString($pictID, "int"),
GetSQLValueString(isset($_POST['Certify']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_PROFILES, $PROFILES);
$Result1 = mysql_query($insertSQL, $PROFILES) or die(mysql_error());
$insertGoTo = "addmorephotos.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
}
}