Jump to content

works on Firefox, Opera but not in IE ??


saumya

Recommended Posts

hi guys,

I have a form, which submits data to a DB and uploads a photo to the server.While the script works just nice in Firefox and Opera, it is not working in IE ?

With IE, the data gets into the DB but the photo does not upload.

Here is the link to the view page

http://www.subhvivaah.in/sam_simple_cms/index.php

 

The form is at below link

http://www.subhvivaah.in/sam_simple_cms/admin.php

 

Thanking you

saumya

 

Link to comment
Share on other sites

Thank you people, for your answers.But is it really works in IE?!!

 

Actaully the data gets into the DB but the problem is the image.It does not upload in IE !!

Here is the code I am using to upload the image

$upload_error=$_FILES['photo']['error'];
                switch($upload_error) {
                        case 0: //no error; possible file attack!
                                echo 'no error; possible file attack!';
                                break;
                        case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
                                echo 'uploaded file exceeds the upload_max_filesize directive in php.ini';
                                break;
                        case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
                                echo 'uploaded file exceeds the MAX_FILE_SIZE ( 10 KB ) directive that was specified in the html form';
                                break;
                        case 3: //uploaded file was only partially uploaded
                                echo 'uploaded file was only partially uploaded';
                                break;
                        case 4: //no file was uploaded
                                //$error = $error . $upload_error . ": " . $upload_error_lang[$upload_error];
                                echo 'no file was uploaded';
                                break;
                        default: //a default error, just in case!  Smile
                                $error ="<br/><br/>". $error . $upload_error . ": " . $upload_error_gen_lang;
                                break;
                } 

Link to comment
Share on other sites

Thats the results filter but not the file handler.  Is ther more that is used to determine where it may be having a fault.. I'm supprised for one that it works in Firefox and not IE..  Firefox is pretty strict about what it shows people compared to IE.

Link to comment
Share on other sites

ok, here are my scripts.

The main page is

<?Php
//includes..................the necessary Scripts..............................
 include_once('php_includes/connectdb.php');
 include_once('php_includes/img_upload.php');
 //............END..............include.......................................................
echo<<<HERE
<html>
<head>
<title>Thane Guide : simple CMS</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<LINK REL="stylesheet" HREF="final.css" TYPE="text/css">
HERE;
?>
<script language="javascript" type="text/javascript" src="javascript/downLoaded/datetimepicker.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
//Addign page specific functions
function checkAndSubmit()
{
var pName=document.add_item.item_name.value;
if(pName=='')
{
alert ( 'Please fill the form' );
}else{
//alert ( 'Submitting : '+pName );
document.add_item.submit();
}
}
//-->
</script>
</head>
<body>
<form action="admin.php" name="add_item" method="POST" enctype="multipart/form-data" >
	Product Name : 	<input type="text" name="item_name"/><br/>
				<input type="Hidden" name="MAX_FILE_SIZE" value="10000"/>
	Image : 		<input type="file"  name="photo" /><br/>
	Details : 		<textarea cols="50" rows="10" name="item_detail"></textarea></br>
	Entry date : 
					<!--  Adding Date chooser Calender -->
				<input name="date_of_entry" type="text" size="15" id="entry_date" readonly/>
					<a href="javascript:NewCal('entry_date','YYYYMMDD')"><img src="img/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a><br/>
				<input type="Reset"/>
				<input type="Button" value="Add Product" onClick="checkAndSubmit();"/>
</form>
<?Php
//checks for form submission
if(isset($_POST['item_name'])){
connectDbServer();
selectDB('universal');
//gets from the form submiited
$item_name =   $_POST['item_name'];
$item_detail =   $_POST['item_detail'];
$date_of_entry =   $_POST['date_of_entry'];
$query = "INSERT INTO `basic_cms` (`product_no`, `product_detail`, `date_of_entry`) VALUES ('$item_name', '$item_detail', '$date_of_entry');";
putMyData($query);
//echo "$first_name_student  $last_name_student  is going to be added";
//after putting the data, we will get it to name our file name according to the id of the student in DB
$query = "SELECT * FROM `basic_cms`;";
//Getting the detail values
	if( !$result = mysql_query($query) ){
		die('Could not execute the query to get students\' data : ' . mysql_error());
	}else{
		// get the last auto incremented value
		$lastItemID = mysql_insert_id();
	}
//name the file according to the ID of the student
$filename=$lastItemID;
//upload the photo
uploadTheFile($filename);
}else{
echo 'Please fill the form to add new Product ';
}
?>
</body></html>

 

 

 

Now the upload image page is

 

 

<?Php
//......................................UPLOAD...function..................................................................
function uploadTheFile($filename){
// Where the file is going to be placed 
$target_path = "uploaded_form_images/";
$uploadingfileIs= basename( $_FILES['photo']['type']);
if($uploadingfileIs=='jpeg'){
//First check whether upload has been success ful or not
	if(is_uploaded_file($_FILES['photo']['tmp_name'])){
	//Add the original filename to our target path. Result is "uploads/filename.extension" 
	//$target_path = $target_path . basename( $_FILES['photo']['name']); 
	//Renaming to my preffered name after the file has been uploaded
	//$target_path = $target_path . 'myFile.jpg'; 
	$target_path = $target_path . $filename.'.jpg'; 
		if(move_uploaded_file($_FILES['photo']['tmp_name'], $target_path)) {
			echo " The file ".  basename( $_FILES['photo']['name'])." has been <b>successfully uploaded</b>";
		} else{
			echo "There was an error uploading the file, please try again!";
		}
	}else{
		echo $_FILES['photo']['error'];
	}
}else{
	echo 'Please select <b>only jpeg files</b> to upload. ';
	$upload_error=$_FILES['photo']['error'];
	switch($upload_error) {
		case 0: //no error; possible file attack!
			echo 'no error; possible file attack!';
			break;
		case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
			echo 'uploaded file exceeds the upload_max_filesize directive in php.ini';
			break;
		case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
			echo 'uploaded file exceeds the MAX_FILE_SIZE ( 10 KB ) directive that was specified in the html form';
			break;
		case 3: //uploaded file was only partially uploaded
			echo 'uploaded file was only partially uploaded';
			break;
		case 4: //no file was uploaded
			//$error = $error . $upload_error . ": " . $upload_error_lang[$upload_error];
			echo 'no file was uploaded';
			break;
		default: //a default error, just in case!  
			$error = $error . $upload_error . ": " . $upload_error_gen_lang;
			break;
	}
}
}
//.................................................END UPLOAD.....function.............................................
?>

Link to comment
Share on other sites

Can I ask why exactly it is you only want jpeg pictures because I just been playing round with mine and it would seem it doesn't like jpeg but I know for a fact the below works with both FF and IE

 

 

if ($_FILES["photo"]["type"] == "image/gif" )

 

Just depends on how much you want your pictures to be jpeg

 

Let us know

 

Also as you know:

 

if ($_FILES["photo"]["type"] == "jpeg" )

 

works in FF but not IE and

 

if ($_FILES["photo"]["type"] == "image/pjpeg" )

 

works in IE but not FF

Link to comment
Share on other sites

ohh maan, thank you sooooooo much  ;) !!

 

That worked great for me too  :D .

Look at

http://www.subhvivaah.in/sam_simple_cms/index.php

 

last 2 images are gif and both worked in both the browsers. I can go ahead with my project in GIF.Thank you so much.

 

But the question is still there for JPEG. I would really like o dive into the complexions happening in JPEG .

 

Link to comment
Share on other sites

hi magnetica ,

thank you so much. I appreciate your help and concern. I am completely agreed that gifs are smaller and stuff. But I was wondering how PHP is handling the files.

 

Well, for the solution to JPEGs, I also thought the same, to put a check for both. Lets see if we can make it any other way.

 

Cheers magnetica and thank you for your help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.