简体   繁体   English

如何将路径绑定到Asp.net C#中的FileUpload

[英]How will bind a path to FileUpload in Asp.net C#

I am tried to bind a path select from database to my FileUpload Control.I couldnot bind the path to my Fileupload control .then how will give my selected data(path) to Fileupload control. 我试图将数据库中的路径选择绑定到我的FileUpload控件。我无法将该路径绑定到我的Fileupload控件。那么如何将我选择的数据(路径)提供给Fileupload控件。 Everybody tells only about how will take value from Filupload. 每个人都只说说如何从Filupload中获取价值。 what is wrong in my code mentioned below?. 下面提到的我的代码有什么问题? pls give how will bind a value from database to Fileupload control. 请给出如何将值从数据库绑定到Fileupload控件。

string id= ddid.SelectedValue.ToString();
string  qry = "select photo from EmpMaster where MachID='" + id+"'";
dr = conn.query(qry);
if (dr.Read())
{
    ImgPic.ImageUrl= dr[0].ToString();
    if (FileUpload1.HasFile)
    {
        FileUpload1.PostedFile.FileName.Insert(0, ImgPic.ImageUrl);
    }
}

You cannot bind a path to the file upload control. 不能将路径绑定到文件上传控件。 This is for security reasons; 这是出于安全原因; the browser requires the client to choose a file to upload. 浏览器要求客户端选择要上传的文件。

If you want to display the filepath use something like a Label . 如果要显示文件路径,请使用Label

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM