如何获得完整的文件路径 [英] How to get full filepath

查看:87
本文介绍了如何获得完整的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天,我希望在提交表单数据时获取系统上文件的完整路径。

这是我查看文件输入标签的位置

Good day, i want to get the fullpath to a file on my system when i submit a form data.
this is my view where the file input tag is located

<input name="ad1file" type="file" id="passport" required>





这是我的控制器



this is my controller

string path = Request.Files["ad1file"].FileName;
               FormData fd = new FormData
               {
                   ad1file = Path.GetFullPath(path)
               };





函数GetFileName()返回文件名,GetFullPath()返回绝对路径,两者都不是t指向我的文件。

当我用它显示它时,我看不到任何图像



the functions GetFileName() returns the file name and GetFullPath() returns the absolute path, both of which isn't pointing me to the file.
and when i displayed it using this, i don't see any image

<img name="ad1pass" src="@Model.ad1file" alt="passport" width="150" height="150">



感谢您的光临你的帮助


Thanks for your assistance

推荐答案

这似乎是完全在服务器端运行的ASP.NET代码。如果您希望获得客户端发送的完整文件路径,则不会发生这种情况。服务器无法访问,也不应该关心文件来自客户端的路径。
This appears to be ASP.NET code which runs entirely server side. If you're expecting to get a full file path sent by the client it's not going to happen. The server will not get access to, nor should it ever care about, what path the file came from on the client.


这篇关于如何获得完整的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆