I have a html form to take file input and on upload , upload.php is called and the file is uploaded to the server. I want to stay on the same page and display the upload status on a label in the form. I am using a session variable that gets updated in upload.php , i am echoing $_SESSION['status'] into the label.
<form action="upload.php" method="post" enctype="multipart/form-data">
               <div id="fileDiv">
                   <?php $_SESSION['status']=" ";?>
                <h3>Select file to upload:</h3>
                 <div class="form-group"><input type="file" name="fileToUpload" id="fileToUpload" required="true" ></div>
                 <div class="form-group"><input type="submit" value="Upload" name="submit" id="fileUpload"></div>
                 <div class="form-group"><label><?php echo $_SESSION['status']?></label></div>
               </div>
             </form>  
upload.php
     <?php
session_start();
include ("./PHPExcel/IOFactory.php");
include_once('./PHPExcel/PHPExcel.php');
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Allow only Excel doc
if($FileType != "xlsx" && $FileType != "xls" ) {
    $_SESSION['status']= "Only excel(.xls or .xlsx) files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) 
    $_SESSION['status']="file was not uploaded.";
 else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) 
        $_SESSION['status']="File uploaded";
    else 
      $_SESSION['status']="error uploading your file.";
} ?>
Is there an AJAX solution which is alternative to enctype="multipart/form-data" ? . The file uploads successfully, just that I want to stay on the same page.
