Header

Welcome to Site Talk Zone, the place to talk about doing business online! Our discussion forums include online business planning, design, development, and marketing. We welcome all online business owners to participate and join us!

Registration is simple, quick and free. Join us right now and enjoy the benefits of all the features that Site Talk Zone offers.




PHP Pre Hypertext Processor, the best known development language employed to create dynamic websites with the help of some common database solutions. Any discussions regarding PHP go in this section

Reply
Old 11-27-2009, 06:49 AM   #1 (permalink)
New Round here!
 
Join Date: Nov 2009
Posts: 1
Credits: 191
Thanks: 0
Thanked 0 Times in 0 Posts
amber.long83 is on a distinguished road
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0% Activity: 0% Activity: 0%
Default Image upload problem

Hello everyone

I am getting confused with my image upload code. It works fine in mozila firefox
But It dosen't seems to be work in IE.

Any one can please helme what changes I should do in the code or where I done mistake.

Code

$target_path = "./temp/";

$size = $_SERVER['CONTENT_LENGTH'];
if ($size > 2999999)
{
$_SESSION['msg'] = "Image is to big for upload, please resize image!";
$back = $_SERVER['HTTP_REFERER'];
header("location:$back");
break;
}
//////////////////////////////////////////////////////////

$image = $target_path . basename( $_FILES['image']['name']); // complete image name

////////////// look for the right type of picture ////////////////////////
if ($target_path != "")
{
if(($_FILES["image"]["type"] == "image/jpeg") || ($_FILES["image"]["type"] == "image/png") || ($_FILES["image"]["type"] == "image/jpg"))
{
$pic = basename( $_FILES['image']['name']);

if(!move_uploaded_file($_FILES['image']['tmp_name'], $image))
{
$_SESSION['msg'] = "There was an error uploading the file, please try again!";
$back = $_SERVER['HTTP_REFERER'];
header("location:$back");
break;
}
}
else
{
$_SESSION['msg'] = "Invalid image type, please upload a jpeg or png image!";
$back = $_SERVER['HTTP_REFERER'];
header("location:$back");
break;
}
}
////////////////////////////////////////////
else
{
$image = "images/empty.jpg"; // if picture could not be uploaded load dummy picture
}
///////// get image type ////////////////
list($width, $height) = getimagesize($image);
$size = getimagesize($image);
$type = explode(".",$image,3);
$type = $type[2];

//////////////////////////////////// Resize image en type /////////////////////////

if ($type == "jpg" || $type == "JPG") // if it is a jpeg
{
$small = "./temp/small.jpg";
$big = "./temp/big.jpg";
$pic_s = resizejpg_small($image);
$pic_b = resizejpg_big($image);

imagejpeg($pic_s,$small,80); // compress image op 20%
imagejpeg($pic_b,$big,80);// compress image op 20%

$fp = fopen($small, "rb");
$small = mysql_escape_string(fread($fp, filesize($small))); // makes image blob compatible and $small inserted in db
$fp = fopen($big, "rb");
$big = mysql_escape_string(fread($fp, filesize($big))); // makes image blob compatible en $big inserted in db
}
elseif($type == "png" || $type == "PNG") // if image is png
{
$small = "./temp/small.png";
$big = "./temp/big.png";
$pic_s = resizepng_small($image);
$pic_b = resizepng_big($image);

imagepng($pic_s,$small);
imagepng($pic_b,$big);

$fp = fopen($small, "rb");
$small = mysql_escape_string(fread($fp, filesize($small)));
$fp = fopen($big, "rb");
$big = mysql_escape_string(fread($fp, filesize($big)));
}


Thanks in Advance
__________________
A leading
To view links or images in signatures your post count must be 0 or greater. You currently have 0 signatures.
for php development
amber.long83 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

« WAMP or XAMPP? | - »
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:03 PM. vBulletin® | Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
All Rights Reserved - SiteTalkZone | Intelligent Internet Business Chat






1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63