问题
How to get Physical path of working folder in jscript or jquery?
What i need is when a dropdown is selected or if a button is clicked i need to get complete path of the working folder.
ex:
var x="path" here x should be x=E:/projects/projectname/xyz.aspx.
i dont want url of current docuent, i want complete path, so that i can generate new aspx page and place in that folder dynamically.
回答1:
I think you are looking for something like this:
var x = ('<%=HttpUtility.JavaScriptStringEncode(Server.MapPath(Request.Url.LocalPath))%>');
Now, how useful is that information on the client side is something that's not clear to me, besides being risky, in my opinion...
On my PC, it prints this if I do console.log(x)
:
\\company\home_drives$\rsanchez\visual studio 2012\Projects\test\test\Default.aspx
回答2:
Browser run in sandboxes, that mean that client scripting is forbidden to access the file system.
回答3:
You would need to collect all of the physical paths on the server, and pass them to the client. If you wanted the entire folder structure, you'd have to pass it down to the client and construct the folder structure.
I assume you are referring to something like a file manager that a hosting company might use.
来源:https://stackoverflow.com/questions/14161460/how-to-get-physical-path-of-working-folder-in-javascript-or-jquery