There are six inverter and each inverter generates csv file which contains details about the inverter. I was Creating an application where user will select the Inverter no and uploads the excel file.
But the problem is, User can select inverter one and can upload inverter 2 csv file…Thus entering wrong data.
Each csv file first column first cell(A1 cell) contains Inverter number…What is the Php code to check that cell value against what user selection…
My html code:
<h2>Select The Inverter No...</h2>
<label for="Inverter">Inverter</label>
<select name="options">
<option>Select The Value</option>
<option value="1">Inverter 1</option>
<option value="2">Inverter 2 </option>
<option value="3">Inverter 3</option>
<option value="4">Inverter 4</option>
<option value="5">Inverter 5</option>
<option value="6">Inverter 6</option>
</select><br/>
<label for="upload">Upload File</label>
<input type="file" name="file" id="file" class="Upload" onchange="validate_fileupload(this.value);" /><br/><br/><br/>
<input type="submit" value="submit" name="submit" class="button"/>
My .php code:
if(isset($_POST["options"],$_POST["submit"])){
$count=0;
if($_FILES["file"]["size"] > 0)
{
$file = fopen($filename, "r");
while (($check = fgetcsv($file, 10000, ",")) !== FALSE)
{
if($count == 0) {
$count++;
if ($check[0] == "INVERTER"+$inverter)
{
echo "<script type=\"text/javascript\">
alert(\"It's inverter one associated file.\");
</script>";
}
{
echo "<script type=\"text/javascript\">
alert(\"File is not assosiated with inverter one.\");
</script>";
}
My csv file:
A B C D
1 Inverter6
2 My Plant
3
4 11-02-2016 13:59
5 25-04-2014 11:29
6 Serial number (CTRL; POW; AUX; COMM): 056303T353 078001T383 049222T453
7 Product number (CTRL; POW; AUX; COMM): 139B0120 139B0121 139B0501
8 Software version (CTRL; POW; AUX; COMM): 1.49.1 0.00.0 0.00.0 3.60.6