PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



Picture upload problem with Internet Explorer

 
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General
View previous topic :: View next topic  
Author Message
Lalla



Joined: 25 Nov 2009
Posts: 1

PostPosted: Wed Nov 25, 2009 11:39 am    Post subject: Picture upload problem with Internet Explorer Reply with quote

hi there,

can anyone please help me with this problem!!!
my picture upload code works fine in firefox but doesn't seem to work in IE. :banghead:

Can anyone please tel me what i'm doing wrong or what i should change.

Here's the code:
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)));
}
Back to top
View user's profile Send private message
lostboy



Joined: 02 May 2004
Posts: 5868
Location: toronto, canada

PostPosted: Thu Dec 03, 2009 4:48 pm    Post subject: Reply with quote

This code look ok at a glance.

What is the html form to upload the image?

Perhaps there is an issue with the session on IE? Like maybe IE is not setting a session properly in the browser due to settings?
_________________
Lostboy

Cat, the other other white meat

Please read Posting Etiquette before posting

You can always try Google
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
manmada



Joined: 14 Dec 2009
Posts: 5
Location: Bangalore, IN

PostPosted: Mon Dec 14, 2009 9:37 am    Post subject: Reply with quote

http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_FILE.html
Please refer the above, as it explains the html form properties to do upload functionality implementation.
Back to top
View user's profile Send private message
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



PHP Code Examples
 Stream diffrent sizes of images from a single image to save disk space.
 JavaScript dropdown list menu to switch any page.
 Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
 PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside.
 Link Extractor - This function is used to extract links from a given URL. This will convert relative path into absolute path and also remove PHPSESSID stuff.
 Building a Dynamic Form using Javascript and innerHTML. Add form elements in realtime without refreshing the page.
 A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum






Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum