如何使用js获取本地系统文件路径 [英] How to get local system file path using using js

查看:154
本文介绍了如何使用js获取本地系统文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想使用browse上传文件,请在浏览器中选择我们想要本地系统路径的文件后,例如:本地系统路径可能是C:/UserName/Download/ABC.txt。



我尝试过:



如果我想使用上传文件browse.but在浏览器中选择我们想要本地系统路径的文件后,例如:本地系统路径可能是C:/UserName/Download/ABC.txt。

解决方案

< blockquote>你出于安全原因无法得到这些信息,无论如何它对你没有任何实际价值。


你根本无法得到它:除了在几乎没有发生的情况下所有这些天:你的用户必须运行IE,他必须接受ActiveX控件,他必须允许ActiveX控件运行。几乎没有人运行IE,并且出于安全原因默认禁用其他两个(因为ActiveX控件可以访问客户端文件系统并导致恶意代码的大量问题)。



标准JavaScript无法访问主机文件系统,包括路径 - 实际上主机甚至可能没有基于路径的文件系统,它可能是支持互联网的冰箱,或者烤面包机!例如! >
所有你可以访问的是文件名和文件内容:并且使用必须指定文件。



想一想:如果你能做到恶意网站也是如此。我们现在有足够的勒索软件问题 - 如果您只是需要访问一个网站并且它可以访问您的文件系统,您能想象损坏吗?


Like if i want to upload a file using browse.but after select the file we want local system path in browser ,Example : Local System Path may be "C:/UserName/Download/ABC.txt".

What I have tried:

Like if i want to upload a file using browse.but after select the file we want local system path in browser ,Example : Local System Path may be "C:/UserName/Download/ABC.txt".

解决方案

You can't get this information for security reasons, and it's of no real value to you anyway.


You can't get it at all: except in conditions which hardly occur at all these days: your user must be running IE, he must accept ActiveX controls, and he must permit ActiveX controls to run. Hardly anyone runs IE, and the other two are disabled by default for security reasons (because ActiveX controls can access the client filesystem and that caused a load of problems with malicious code).

"Standard" JavaScript cannot access the host file system and that includes paths - and indeed the host may not even have a path-based file system, it could be an internet enabled fridge, or a toaster for example!
All you can access is the filename, and file content: and the use must specify the file.

Think about it: if you could do it, so could malicious sites. And we have enough problems with ransomware these days - can you imagine the damage if you just needed to visit a site and it could access your file system?


这篇关于如何使用js获取本地系统文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆