将消息从一个php文件传递到另一个php文件,拒绝工作

I'm implementing a drag'n'drop code with javascript and HTML5 to upload/save images to the server.

On the server side I have a php file to handle the saving process.

I want the server side php file to be able to send the right messages to the client. Messages like "Saved", "Error" , "Not An Image" etc.

So, the simplest way I thought is using header('Location:multinsert2.php?er1=1'); on the server side and on the client side if ($_GET['er1']) {echo 'Saved.</br>';}.

This does not work. On the server side file I have only php. The client side file ends with .php

Maybe does not work because I use javascript and XHR2 at the front side, instead of a simple upload form? I'm only asking because I give the user the alternative to upload using a simple form, if she has an old browser. And if she does use the form, the messages render fine...

I cant see how to fix this, I got brain-freeze

Any help? Thanks

The code... multinsert2.php, client side, snipets for upload image and render messages

var xhr = new XMLHttpRequest();
      xhr.open('POST', 'upload.php');
      xhr.onload = function() {
                  if (xhr.status === 200)         
                  {                                      
                              progress.value = progress.innerHTML = 100;
alert('all ok');                      
          } 

        else {alert('hmmm, not today');}
      };
xhr.send(formData);

<?php
if ($_GET['er1']) {echo 'error.</br>';}
if ($_GET['er2']) {echo 'uploaded.</br>';}
if ($_GET['er3']) {echo 'image already exists.</br>';}
if ($_GET['er4']) {echo 'saved.</br>';}
if ($_GET['er5']) {echo 'error, invalid file.</br>';}
?>

upload.php, server side, handling the file snippets

if ((($_FILES["file"]["type"] == "image/gif")
 || ($_FILES["file"]["type"] == "image/jpeg")
 || ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 4000000))
if ($_FILES["file"]["error"] > 0)
     {
         header('Location:multinsert2.php?er1=1');//error
}
else
{header('Location:multinsert2.php?er2=1');//uploaded
}
     if (file_exists("cultmapsite/upload" . $_FILES["file"]["name"]))
       {
            header('Location:multinsert2.php?er3=1');//image already exists

       } 

       else
       {
       move_uploaded_file($_FILES["file"]["tmp_name"],
       "upload/" . $_FILES["file"]["name"]);
        header('Location:multinsert2.php?er4=1');//saved

    }
     }
   }
 else
   {
       header('Location:multinsert2.php?er5=1');//error, invalid file

   }

Have a look at the php manual entry: http://php.net/manual/en/session.upload-progress.php