简体   繁体   English

如何在 Node.js 中获取上传文件的路径和名称

[英]How to get Path and name of the Uploaded file in Node.js

Well I am creating a react based web application in which I want to upload docx/pdf and convert it to pdf/docx.好吧,我正在创建一个基于 React 的 Web 应用程序,我想在其中上传 docx/pdf 并将其转换为 pdf/docx。 For security reason there is no way to get file path in react.出于安全原因,无法在反应中获取文件路径。 I wanna use libreoffice-convert package for above reason in which one should provide path of the file.由于上述原因,我想使用 libreoffice-convert 包,其中应该提供文件的路径。 I have heard that one can get path using node script but I am not able to figure it out.我听说可以使用节点脚本获取路径,但我无法弄清楚。

Can somebody help me out by answering following questions有人可以通过回答以下问题来帮助我吗

1.) Should I write file uploading code in Node.js script to get the path of the file? 1.) 我应该在 Node.js 脚本中编写文件上传代码来获取文件的路径吗?
2.) What are other ways to get file path (other than Node.js )? 2.) 获取文件路径的其他方法是什么(除了 Node.js )?
3.) If there is other way to get file path than Node.js then can I configure it in react? 3.) 如果除了 Node.js 之外还有其他获取文件路径的方法,那么我可以在 react 中配置它吗?

Please share any resource that can help me in doing the above task.请分享任何可以帮助我完成上述任务的资源。 Sorry for the poor english.抱歉英语不好。

Thank you in advance先感谢您

Use multer for handling file attachment in node js .使用 multer 处理 node js 中的文件附件。 multer will download the file and save it in provided path multer 将下载文件并将其保存在提供的路径中

docmentation of multer multer文档

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

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