PHP import failed
<p>I've created an PHP upload page in-order to upload xls file from pc to MySQL table, and the whole process works pretty well as needed except for two issues.
Suppose the user who is making the upload, accidentally closed browser, or clicked over another link ; In that case the partial items are uploaded to MySQL table and the rest are failed. How can I either force the user to wait until the upload is done or maybe create a confirm box by which if it returns false it will erase the items that have been uploaded.</p>

<p>And the other issue - is there a way I can disable upload button after submission, I've searched the google and found many solutions but none of them works for Chrome browser.</p>

<p>If you want here is my upload PHP code:</p>

<p><strong>This shows Loader gif after submitting form</strong> </p>

<pre><code>&lt;script type="text/javascript" src="jquery-1.7.1.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
&lt;!--Loader--&gt;
function getVal(){
$('#load').load('loader.htm');
}
&lt;!--End of Loader--&gt;
&lt;/script&gt;
</code></pre>

<p><strong>Upload File</strong></p>

<pre><code>&lt;form enctype="multipart/form-data" method="post" &gt;
&lt;table width="100%" height="%" align="center" border="1" cellpadding="4" cellspacing="0"&gt;
&lt;tr&gt;&lt;td align="center" colspan="2"&gt;&lt;img src="images/import.png" width="108" height="108"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&lt;input type="file" name="file" id="file"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr &gt;
&lt;td colspan="2" align="center" height="70px"&gt;&lt;br /&gt;&lt;br /&gt;&lt;input type="submit"  onClick="getVal()" name="Import_items" value="Import Items"  style="background-color:orange; font-weight:bold; font-size:16px; width:200px; height:50px;"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;/form&gt;

&lt;center&gt;
&lt;div id="load"&gt;&lt;/div&gt;
&lt;/center&gt;
</code></pre>

<p><strong>After Submitting</strong> </p>

<pre><code>if(isset($_POST["Import_items"]))
{

$filename=$_FILES["file"]["tmp_name"];

if(empty($filename)){
?&gt;
&lt;script&gt;
alert('Error : Please Select Excel File to Import !');
location.replace('import.php');
&lt;/script&gt;
&lt;?php   
exit();
}



//Check File Extension if Valid or Not (Excel Only Format)
$allowed =  array('csv','xls','xlsx');
$ff = $_FILES['file']['name'];

$ext = pathinfo($ff, PATHINFO_EXTENSION);
if(!in_array($ext,$allowed) ) {
    echo "&lt;center&gt;Extension is Not Excel !&lt;/center&gt;";
    ?&gt;
    &lt;script&gt;
    alert('Error : Please Upload Correct Excel File Extension');
    location.replace('import.php');
    &lt;/script&gt;
    &lt;?php
    exit();
}



$date = date('Y-m-d');



/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');

/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';


$inputFileName = $filename;  // File to read
//echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format&lt;br /&gt;';
try {
    $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
} catch(Exception $e) {
    die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e-&gt;getMessage());
}



$sheetData = $objPHPExcel-&gt;getActiveSheet()-&gt;toArray(null,true,true,true);



$num = count($sheetData);

for($i=2;$i&lt;=$num;$i++){

if($sheetData[$i]['B'] ==0 &amp;&amp; $sheetData[$i]['C'] ==0){

       Something 1


}
else {

        //Something 2       


        if(!empty($sheetData[$i]['E']) &amp;&amp; (!empty($sheetData[$i]['E']))){
            //Do Something

            }
            else{
            // Do something Else
            }
            }


        }

}

//For Loop end
}
</code></pre>

<p>Thanks Guys, Any help would be appreciated !</p>