查找文件上传的源路径? [英] Find Source path of file upload ?
本文介绍了查找文件上传的源路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生
我想知道从文件上传到文件上传控件的文件的完整路径.
问候
Jaspreet Singh
Sir
I want to know the full path of file from where file is uploaded to fileupload control.
Regards
Jaspreet Singh
推荐答案
不幸的是,您无法在较新的浏览器上获得客户端系统的完整路径.
客户端系统的目录结构与任何Web服务器都不相关,因此此功能已在较新的浏览器中撤消.
您可以尝试-
Unfortunately you can''t get full path of a client''s system on newer browsers.
The client system''s directory structure is irrelevant to any web server and thus this feature has been withdrawn in newer browsers.
You may try -
FileUpload1.PostedFile.FileName;
但是正如我所说,这仅适用于IE 5.5等较旧的浏览器.我认为,即使IE6也不支持显示完整路径.
我只是好奇者,为什么您要客户计算机的完整路径?您正在使用Internet应用程序吗?
But as I said, this will only work in older browsers like IE 5.5. I think even IE6 doesn''t support revealing full path.
I was just curios why do you want a full path of a client''s machine? Are you working on an interanet application?
您可以通过GetFullPath
方法进行检查.看一下
you can check it byGetFullPath
method. take a look how
if (FileUpload1.HasFile)
{
string filepath = Path.GetFullPath(FileUpload1.FileName); //Returns absolute path for specified file by fileupload control.
Label1.Text = filepath;
}
else
{
Label1.Text = "No uploaded file";
}
注意:-Path
是一个驻留在System.IO
名称空间中的类.因此,在使用命令之前不要忘记提及它.
Note:- Path
is a class which resides in System.IO
namespace. so don''t forget to mention it before using command.
这篇关于查找文件上传的源路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文