How to get the file path in html lt;input type=quot;filequot;gt; in PHP?(如何获取html中的文件路径input type=file在 PHP 中?)
问题描述
谁能告诉我如何在 PHP 中使用 html <input type="file">
获取文件路径?
Can somebody pls tell me how to get the filepath using html <input type="file">
in PHP?
这是我的代码:
index.php
和csv_to_database.php
我的问题是,它仅在 csv 数据与我的 php 文件位于同一目录中时才有效.我想我需要获取文件路径,但我不知道该怎么做.
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.
推荐答案
你不应该只使用你现在拥有的 $_GET
.您的文件基于 $_FILES["csv_file"]["tmp_name"]
.
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:
你可以从那里去.如果您想从临时位置移动文件,请使用 move_uploaded_file
,教程中也有说明:)
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 :)
这篇关于如何获取html中的文件路径<input type="file">在 PHP 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!