简体   繁体   中英

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. Everybody tells only about how will take value from Filupload. what is wrong in my code mentioned below?. pls give how will bind a value from database to Fileupload control.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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