Is the isset() function below placed correctly?
<p>I have this code below and the problem is that it is not uploading the file and the call back javascript function at the bottom isn't displaying the result. Now before I entered in the if isset ($_POST[fileImage'])... code, and the <code>$_SESSION['fileImage']['name'] = $_FILES['fileImage']['name'];</code>, then the files uploaded perfectly.But with those 2 pieces of code, it has stopped the uploading from happening.</p>

<p>So I believe the problem is that the code above I have used have been placed in the wrong places. How can the code below be placed correctly in the right places for the uploading to start working again?</p>

<p>Below is the code which is suppose to upload the files but fails:</p>

<pre><code>  &lt;?php

    $result = 0;

       if (isset($_POST['fileImage']) &amp;&amp; ((($_FILES["fileImage"]["type"] == "image/gif")
    || ($_FILES["fileImage"]["type"] == "image/jpeg")
    || ($_FILES["fileImage"]["type"] == "image/pjpeg")
    || ($_FILES["fileImage"]["type"] == "image/jpg")
    || ($_FILES["fileImage"]["type"] == "image/png")
    || ($_FILES["fileImage"]["type"] == "image/tif"))){

    if( file_exists("ImageFiles/".$_FILES['fileImage']['name'])) {  

        $parts = explode(".",$_FILES['fileImage']['name']);
        $ext = array_pop($parts);
        $base = implode(".",$parts);
        $n = 2;

        while( file_exists("ImageFiles/".$base."_".$n.".".$ext)) $n++;
        $_FILES['fileImage']['name'] = $base."_".$n.".".$ext;

        move_uploaded_file($_FILES["fileImage"]["tmp_name"], 
        "ImageFiles/" . $_FILES["fileImage"]["name"]);
        $result = 1;

    }
        else
          {
          move_uploaded_file($_FILES["fileImage"]["tmp_name"],
          "ImageFiles/" . $_FILES["fileImage"]["name"]);
          $result = 1;

          }

          ?&gt;

&lt;script language="javascript" type="text/javascript"&gt;
window.top.stopImageUpload(&lt;?php echo $result;?&gt;);
&lt;/script&gt;   

          &lt;?php

    }

      $_SESSION['fileImage']['name'] = $_FILES['fileImage']['name'];

    ?&gt;
</code></pre>
