简体   繁体   English

如何将变量从 html 传递到 node.js

[英]how to pass a variable from html to node.js

so I have this app that reads a file uploaded from the client (index.html) I want to get the file that was uploaded on html and user it on my app.js to read it.所以我有这个应用程序可以读取从客户端上传的文件(index.html) How do I do that.我怎么做。 Here goes the files bellow:下面是文件:

index.html index.html

 <input type="file" id="myFile" name="filename">
 <input type="submit">

app.js应用程序.js

 var fs = require('fs');
 var readMe = fs.readFileSync(??? , 'utf8');
 console.log(readMe);

This should return you the full path of the selected file:这应该会返回所选文件的完整路径:

var readMe = fs.readFileSync(document.getElementById("myFile").value , 'utf8');

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

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