How to get rid of the undefined index below?
I am getting an error stating that fileImage is an undefined index on this line: $idx = count($_POST ['fileImage']) -1 ;. Now this is happening because when user opens up the page, then obviously nothing is posted to fileImage, so how can I set it to "", when nothing is posted to the $_POST? I thought I did it in the line below but it doesn't seem that is happening.

Below is the code: 

<?php
session_start();

$idx = count($_POST ['fileImage']) -1 ;
$output = isset($_POST ['fileImage'][$idx]) ? $_SESSION ['fileImage'][$idx]['name'] : "";

?>

          function stopImageUpload(success){

          var imageNameArray = ['<?php echo $output ?>'];
          var result = '';



          if (success == 1){
             result = '<span class="msg">The file was uploaded successfully!</span><br/><br/>';

                for(var i=0;i<imageNameArray.length;i++)
        {
             $('.listImage').append(imageNameArray[i]+ '<br/>');

         }

          }
          else {
             result = '<span class="emsg">There was an error during file upload!</span><br/><br/>';
          }

    return true;

    }
How to get rid of the undefined index below?
===

I am getting an error stating that fileImage is an undefined index on this line: $idx = count($_POST ['fileImage']) -1 ;. Now this is happening because when user opens up the page, then obviously nothing is posted to fileImage, so how can I set it to "", when nothing is posted to the $_POST? I thought I did it in the line below but it doesn't seem that is happening.

Below is the code: 

<?php
session_start();

$idx = count($_POST ['fileImage']) -1 ;
$output = isset($_POST ['fileImage'][$idx]) ? $_SESSION ['fileImage'][$idx]['name'] : "";

?>

          function stopImageUpload(success){

          var imageNameArray = ['<?php echo $output ?>'];
          var result = '';



          if (success == 1){
             result = '<span class="msg">The file was uploaded successfully!</span><br/><br/>';

                for(var i=0;i<imageNameArray.length;i++)
        {
             $('.listImage').append(imageNameArray[i]+ '<br/>');

         }

          }
          else {
             result = '<span class="emsg">There was an error during file upload!</span><br/><br/>';
          }

    return true;

    }