Full path of the file from the remote server

倾然丶 夕夏残阳落幕 提交于 2020-03-05 08:03:34

问题


I am working with files and I don't really understand how to make it work.

I have a web application (c#) that is located on the server and users use this application to upload some information from the files. The problem that I am having that users upload the file (using HttpPostedFileBase class) from their local machines but code is trying to match the same path on the server and of course the file doesn't exist on the server, that's why it throws an error saying that

Cannot find a part of the path ...

If the user is trying to upload the file from C:\Users\User1\Documents\File.txt from their local machine how can I write the code to include the whole path to the file including the computer name and the local drive something like \\ComputerName\c$\Users\User1\Documnets\File.txt.


回答1:


You can't. Client and servers are disconnected from each other. That is how the web works. You can't get the full client path and access that in any way from the server.

There are very good reasons for this, the most important one is security / trust.



来源:https://stackoverflow.com/questions/27609849/full-path-of-the-file-from-the-remote-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!