Image upload not working for IE or firebox


I have a file upload script that uses a iframe to load a image to the server while staying on the same page but for some reason it only works in google chrome and not IE or firefox, can anybody help with this…

here’s the main part of the code for the upload of the image

function startUpload() {
  document.getElementById('photo_uploader').innerHTML="<img src='images/loader.gif' />";
  return true;

function stopUpload(result) {
  if (result == 1) {
    alert('update image');

<!-- BODY BELOW -->

<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
              <div id="photo_uploader">
                <form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload()">
                  <input name="myfile" type="file" size="30" />
                  <input type="submit" name="submitBtn" class="sbtn" value="Upload" />              

And here’s the upload.php script below

$timestamp = time();
$result = 0;
$_FILES["myfile"]["name"] = $timestamp."_".$_FILES["myfile"]["name"];

$filename = $_FILES["myfile"]["name"];

if ((($_FILES["myfile"]["type"] == "image/gif") || ($_FILES["myfile"]["type"] == "image/jpeg") || ($_FILES["myfile"]["type"] == "image/pjpeg")) && 

($_FILES["myfile"]["size"] < 900000))
  if ($_FILES["myfile"]["error"] > 0)
    if (file_exists("upload/" . $_FILES["myfile"]["name"]))
      $filename = "http://server/upload/".$filename;
      "upload/" . $_FILES["myfile"]["name"]);
      $result = 1;
      $query = "UPDATE users SET url = '$filename' WHERE userid='$userID'";


<script language="javascript" type="text/javascript">parent.stopUpload(<?php echo $result; ?>);</script> 

is it something to do with the parent.Function as to why it doesn’t work in IE or firefox?

Thanks in advance?

Well this is a script from

it uses the iframe to stay on the same page while uploading the image.

The funny thing is it works perfect for google chrome browser as in it uploads the image but i can’t seem to get it to work in IE or firefox…

Has anyone used the above script to upload files? is it cross-browser compatible?

I’m not realy familiar with PHP but does it throw any errors or is it simply not uploading? Another question! Do you use the Iframe to stay on the page? In my knowledge you don’t need a IFrame for that. I think you need some kind of exception handling to see what’s going on.