如何在asp.net中获取具有全路径的postedfile的文件名 [英] how to get file name of postedfile with fullpath in asp.net

查看:82
本文介绍了如何在asp.net中获取具有全路径的postedfile的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net网站中,如何获取asp.net中具有完整路径的postedfile的文件名
任何人都可以,请帮助我...

In asp.net website how to get file name of postedfile with fullpath in asp.net
anyone.please help me......

推荐答案

这取决于浏览器.有些浏览器发送了它,有些则没有.由于您无法访问客户端的文件系统,因此不需要它,因此您无法做任何有意义的事情.
This is dependent on the browser. Some browsers sent it, and some do not. As you cannot access the client''s file system, you don''t need it, there''s nothing you can do with it that makes much sense.


You can use javascript to achieve this before submit.

For instance<asp:button onClientClick="document.getElementById('hiddenField1').value = document.getElementById('fileUpload1').value"  ...

Then the path can be retrieved on server side via hiddenField1.Value


如果您正在使用FileUpload Control,那么您可以使用以下代码
HttpPostedFile文件= FileUpload1.PostedFile
字符串StrFileName = file.FileName

注意:StrFileName将存储带有文件完整路径的文件名.........
if you are using FileUpload Control than u can use follwing code
HttpPostedFile file = FileUpload1.PostedFile
String StrFileName = file.FileName

Note: StrFileName will store File Name with full path of file........


这篇关于如何在asp.net中获取具有全路径的postedfile的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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