<?session_start();
include("../opendb.php");
//print sizeof($a);

if($upd)
{
if($ff !="none")
{
   $fl=$HTTP_POST_FILES['ff']['name'];
   $file_dir=".";
  $tmp_name=$_FILES['ff']['tmp_name'];

   move_uploaded_file($tmp_name,"./txtfiles/$file_dir/$ff_name") or die(' err:could not copy file'.$fl);
  print "File copied :".$fl;
 }
$fp=fopen("./txtfiles/$ff_name","r") or die("Cant open file");
$i=1;
include("../opendb.php");
//mysqli_query($db,"delete from sparelocmast where brcode='$brcode'")or die('Err:'.mysqli_error($db));

$i=1;
while(!feof($fp))
{
 $line=fgets($fp,1024);
 $spline=explode("\t",$line);
if(strlen($spline[0])>0)
{
$sql="insert into sparelocmast values('".addslashes(trim($spline[0]))."','".addslashes(trim($spline[1]))."','".addslashes(trim($spline[2]))."','".$brcode."')";
mysqli_query($db,"delete from sparelocmast where itemcode='$spline[0]' and brcode='$brcode'");
print $i++.". ".$sql."<br>";
mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));
}
}
print "<script> alert('Done');</script>";
}

?>

<link rel="stylesheet" href="style.css" type="text/css" />
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
//etr{background-color:c1d799}
.mnu{margin-left:5}
</style>
<center>
<br><br><br><br><br><br>
Itemcode -  Item Name - Location-(Branch)<br>
<form action='<?print $PHP_SELF?>' method='post' ENCTYPE="multipart/form-data">
<table border=0 width=60% cellspacing=1 cellpadding=1 bgcolor='darkbrown'>
<tr><td align=center bgcolor=white>
<table >
<th colspan=2 bgColor=c1d799>Upload Location Master
<tr><td>File </td><td><input type=file name='ff'></td></tr>
<tr bgColor='lightsteelblue'><td align=center colspan=2 ><input type=submit value='Upload' name='upd'></td></tr>
</table>
</td></tr>
</table>
</form>
