开发者

How to get the uploaded file path?

开发者 https://www.devze.com 2023-04-02 21:34 出处:网络
I am using input tag type=\"file\" to browse the file in asp.net. I browsed the file \"Linq2sql.zip\" f开发者_Go百科rom the location \"c\\Desktop\\Karthik\\Linq2sql.zip\".

I am using input tag type="file" to browse the file in asp.net.

I browsed the file "Linq2sql.zip" f开发者_Go百科rom the location "c\Desktop\Karthik\Linq2sql.zip".

i can get the file name and path using

HttpPostedFileBase file;
var filePath = Path.GetFullPath(file.FileName);  

But File path is like = C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\DevServer\\10.0\\Linq2sql.zip

i have to get the original file path c\\Desktop\\Karthik\\Linq2sql.zip. How can i get?


You can not get the original path of the file on the client system; that information is not sent by the client.

The reason you get what you do with GetFullPath is because that forces a resolution with the simple file name alone with the current directory of the asp.net process. That info is utterly meaningless - and in fact incorrect - in this case.

0

精彩评论

暂无评论...
验证码 换一张
取 消