简体   繁体   中英

Get File Path in local System in JavaScript

I am trying to get the client local path without hard coding in JavaScript. I used the below code to get the path, but it is retrieved from the server. Can someone help me how to get local file path in JavaScript.

recordPath = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(
                                          HttpContext.Current.Server.MapPath("saveFile")));

You cannot get an absolute file path via javascript. You can only get file paths relative to the server page.

location.pathname;
location.hostname;

All absolute paths should be handled on the back end, and should not be hard coded into js, which is freely visible to the user.

Javascript does not allow showing drive paths. You can try vbScript for it. Check This Out :

How to get Hard Disk number from drive letter using VBScript

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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