简体   繁体   English

使用javascript获取本地计算机的桌面路径

[英]Get desktop path of local machine using javascript

I need to read a text file in php. 我需要在php中读取文本文件。 But file will vary based on users that which system they are using. 但是文件将根据用户使用的系统而有所不同。

For example user1 access: i want to read a text file from their desktop location like 例如user1访问:我想从其桌面位置读取文本文件,例如

url : "C://Users/user1/desktop/data.txt",

user2 access: i want to read a text file from their desktop location like user2访问权限:我想从其桌面位置读取文本文件,例如

url : "C://Users/user2/desktop/data.txt",

so i want to get the current machine desktop path as C://Users/{username}/desktop by using Javascript/PHP? 所以我想使用Javascript / PHP将当前计算机的桌面路径获取为C://Users/{username}/desktop

PHP is a server side language therefore it cannot read stuff on another computer. PHP是一种服务器端语言,因此它无法在另一台计算机上读取内容。 I have actually attempted this before in JavaScript and figured that it is not possible to read a file in any way unless the file is uploaded to the website server. 我实际上已经在JavaScript中尝试过此操作,并且认为除非将文件上传到网站服务器,否则无法以任何方式读取文件。

Sorry but what you are trying to do is not possible probably for security reasons and the fact that websites are meant to run in your browser and not on your computer. 抱歉,您尝试做的事不可能发生,可能是出于安全原因,以及网站应在浏览器中而不是在计算机上运行的事实。

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

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