【问题标题】:how to upload a file in localhost web server, and get the file path如何在 localhost Web 服务器中上传文件,并获取文件路径
【发布时间】:2021-12-27 01:41:05
【问题描述】:

我已经部署了一个网络本地主机,http://localhost:8080 我包含以下代码来获取上传文件。

    <form action="/action_page.php">
      <input type="file" id="myFile" name="filename">
      <input type="submit">
    </form>

我正在尝试在我的 javascript 代码中读取本地 Web 服务器中的文件名和文件路径。 我怎样才能得到这两个?

【问题讨论】:

标签: javascript html css web localhost


【解决方案1】:

您可以使用下面的函数来获取上传文件的名称、文件路径、大小和其他一些信息。

const handleUploadClick = (event) => {
  const file = event.target.files[0]
  console.log(file) // returns an object
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-15
    • 1970-01-01
    • 2021-08-09
    • 2020-09-22
    • 1970-01-01
    • 2016-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多