简体   繁体   English

如何在 localhost web 服务器中上传文件,并获取文件路径

[英]how to upload a file in localhost web server, and get the file path

I've deployed a web localhost, http://localhost:8080 and I included the following code to take a upload file.我已经部署了一个 web localhost、http://localhost:8080 并包含以下代码来获取上传文件。

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

I am trying to read file name and file path in the local web server in my javascript code.我正在尝试在我的 javascript 代码中读取本地 web 服务器中的文件名和文件路径。 How can I get those two?我怎样才能得到那两个?

You can use the below function to get the name, file path, size, and some other information about the uploaded file.您可以使用下面的 function 来获取上传文件的名称、文件路径、大小和其他一些信息。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM