我希望从本地主机上的fileupload控件获取完整的文件路径 [英] I want full Path of file from fileupload control on Local Host

查看:77
本文介绍了我希望从本地主机上的fileupload控件获取完整的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经采取了Fileupload控件,按钮和文本框



因此,当我点击按钮时,我希望文本框中文件上传控件的完整路径文件
..

解决方案

如下所示,您可以在fileupload contorl中获取文件的完整路径:



  string  filePath,fileName; 
if (FileUpload1.PostedFile!= null
{
filePath = FileUpload1.PostedFile.FileName; // 带路径的文件名。
fileName = FileUpload1.FileName; // 仅文件名。
}





或参考以下链接:



http://stackoverflow.com/questions/4242819/getting-the-path-of-a-file-using-fileupload-control [<一个href =http://stackoverflow.com/questions/4242819/getting-the-path-of-a-file-using-fileupload-control\"target =_ blanktitle =新窗口> ^ ]



如果有帮助,请接受回答并投票。


这样做:



 String Path = HttpContext.Current.Request.PhysicalApplicationPath + FileUpload1.FileName; 

或者试试这个String Path = Server.MapPath(FileUpload1.FileName);





希望这会有所帮助你:))。


你可以这样试: -



  string  fileBasePath = Server.MapPath( 〜/) ; 
string fileName = Path.GetFileName( this .MyFileUploader.FileName);
string fullFilePath = fileBasePath + fileName;





仍然如果你没有获得路径然后它的浏览器安全问题。

请参考: -

http://forums.asp.net/t/1077850.aspx [ ^ ]


guys i have taken Fileupload control, Button and Textbox

so when i click on button i want full path of file from fileupload control in the Textbox
..

解决方案

Like below you can get full path of your file in fileupload contorl :

string filePath,fileName;
   if (FileUpload1.PostedFile != null)
   {
       filePath = FileUpload1.PostedFile.FileName; // file name with path.
       fileName = FileUpload1.FileName;// Only file name.
   }



Or refer below link :

http://stackoverflow.com/questions/4242819/getting-the-path-of-a-file-using-fileupload-control[^]

Accept as answer and vote if help to you.


Do in this way :

    String Path = HttpContext.Current.Request.PhysicalApplicationPath + FileUpload1.FileName;

Or try this  String Path = Server.MapPath(FileUpload1.FileName);



Hope this will help you :).


You can try like this:-

string fileBasePath = Server.MapPath("~/");
string fileName = Path.GetFileName(this.MyFileUploader.FileName);
string fullFilePath = fileBasePath + fileName;



Still if you not get path then its issue of browser security.
refer this:-
http://forums.asp.net/t/1077850.aspx[^]


这篇关于我希望从本地主机上的fileupload控件获取完整的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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