How to get the file path in html <input type=“file”> in PHP?

后端 未结 3 1077
[愿得一人]
[愿得一人] 2020-12-02 02:04

Can somebody pls tell me how to get the filepath using html in PHP?

Here are my codes:

index.php

3条回答
  •  执念已碎
    2020-12-02 02:41

    You shouldn't just use the $_GET you've got now. Your file is based in $_FILES["csv_file"]["tmp_name"].

    Best you review this tutorial, that basically says you need to do something like this:

     0)
      {
      echo "Error: " . $_FILES["csv_file"]["error"] . "
    "; } else { echo "Upload: " . $_FILES["csv_file"]["name"] . "
    "; echo "Type: " . $_FILES["csv_file"]["type"] . "
    "; echo "Size: " . ($_FILES["csv_file"]["size"] / 1024) . " Kb
    "; echo "Stored in: " . $_FILES["csv_file"]["tmp_name"]; } ?>

    And you can go from there. Use move_uploaded_file if you want to move the file from the temp location, also explained in the tutorial :)

提交回复
热议问题