code:
<?php
if(isset($_POST['upload']))
{
$filename = $_FILES['files']['name'];
$path = "upload_enq/";
$move = move_uploaded_file($_FILES['files']['tmp_name'],$path.$_FILES['files']['name']);
$path_file = "upload_enq/".basename($_FILES['files']['name']);
$c =0;
$fileObj = fopen( $path_file, "rt" );
if($fileObj){
while(!feof($fileObj)){
$content = fgets($fileObj);
if($content)
$c++;
}
}
fclose($fileObj);
echo $c;
}
?>
<form class="forms-sample" method="post" enctype="multipart/form-data">
<input type="file" name="files" id="files" />
<input type="submit" class="btn btn-success mr-2" name="upload" id="upload" value="Upload" />
</form>
In this code I have create a simple form where I am uploaded csv file and I want to count lenght of csv file. Now what happen when I uploaded csv file which having 295 rows but it shows wrong output it count 926 rows. So, How can I fix this issue ?Please help me.
Thank You