How to get full filepath when uploading files in PHP?

后端 未结 3 1263
花落未央
花落未央 2021-02-10 00:47

I really want to know how am I gonna get the full filepath when I upload a file in PHP?

Here\'s my my problem...

I am importing a csv file in PHP. Uploading a fi

3条回答
  •  渐次进展
    2021-02-10 01:48

    I was able to successfully imported csv file and stored it in the mysql database.

    Here are the the codes (actually its almost the same as my question with some slight changes with great effect):

    index.php:

    csv_import.php:

     0) {
      echo "Error: " . $_FILES['csv_file']['error'] . "
    "; }else{ if (($handle = fopen($_FILES['csv_file']['tmp_name'], "r")) !== FALSE) { $dbconn = mysql_connect("localhost", "root", "") or die("Couldn't connect to server!"); mysql_select_db("csv_test") or die("Couldn't find database!"); $ctr = 1; // used to exclude the CSV header while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($ctr > 1) mysql_query("INSERT INTO ninja_exer (name, village, country) VALUES ('$data[1]', '$data[2]', '$data[3]')"); else $ctr++; } fclose($handle); } } ?>

提交回复
热议问题