简体   繁体   English

使用React JS的绝对文件路径

[英]Absolute file path using react js

Am using Input type 'file' for browsing files in from my machine using react js application , After select the file from my local i want to get the absolute path of my file , ex : C://something/something.png like this . 我正在使用输入类型'file'来使用react js应用程序从本机浏览文件,从本地选择文件后,我想获取文件的绝对路径,例如: C://something/something.png so i searched on many sites , all are telling that from UI we cant access our machine!! 因此,我在许多网站上进行了搜索,所有人都在说从UI我们无法访问我们的机器! .Ok fine , now my doubt here is then how can i achieve that . 好吧,现在我的疑问是我该如何实现这一目标。 can someone help/give_ur_suggestion me on this. 有人可以帮忙吗/给我建议。 thanks in advance . 提前致谢 。

You have to use relative path . 您必须使用相对路径

In practice, you have to put all your assets, source code, ressources, etc. in one directory to ease deployment. 实际上,您必须将所有资产,源代码,资源等放在一个目录中,以简化部署。 Indeed, when you deploy your code, the server is not aware of your computer. 确实,当您部署代码时,服务器并不知道您的计算机。 With relative paths, it can resolve the path to your ressources. 使用相对路径,它可以解析到您的资源的路径。

You can read on Wikipedia the difference betwen relative path and absolute path: 您可以在Wikipedia上阅读相对路径和绝对路径之间的区别:

Absolute and relative paths. 绝对路径和相对路径。 An absolute or full path points to the same location in a file system, regardless of the current working directory. 无论当前工作目录如何,绝对路径或完整路径都指向文件系统中的同一位置。 To do that, it must include the root directory. 为此,它必须包含根目录。 By contrast, a relative path starts from some given working directory, avoiding the need to provide the full absolute path. 相反,相对路径从某些给定的工作目录开始,从而避免了提供完整的绝对路径。

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

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