Can somebody pls tell me how to get the filepath using html <input type="file"> in PHP?
Here are my codes:
index.php
<form action="csv_to_database.php" method="get" >
 <input type="file" name="csv_file" />
 <input type="submit" name="upload" value="Upload" />
</form>
and in csv_to_database.php
<?php
 if (isset($_GET['csv_file'])) {
 $row = 1;
  if (($handle = fopen($_GET['csv_file'], "r")) !== FALSE) {
   while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $num = count($data);
    echo "<p> $num fields in line $row: <br /></p>\n";
    $row++;
    for ($c=0; $c < $num; $c++) {
        echo $data[$c] . "<br />\n";
    }
   }
   fclose($handle);
  }
 } 
?>
My problem is, it only works when the csv data is in the same directory as my php files. I think I need to get the file path but I don't know how to do it.
 
     
     
     
     
    