获取要上传的图片的路径

艾曼

我需要在网格视图中获取所选图像的路径以上传文件。

例如我通过下面的代码在单元格到文本框中的选定值

 txtucname.Text = gridusers.SelectedRow.Cells[1].Text;

如何通过文件上传来实现

编辑任何客户记录时,如果用户未选择任何图像,则会删除前一个图像。

if (imgup.HasFile)
{
    string imgName = imgup.FileName.ToString();
    imgup.SaveAs(Server.MapPath("../Images/Customer/") + imgName);
    string imgPath = "../Images/Customer/" + imgName;
    string msg = c.UpdateCustomer(txtcustid.Text, txtucname.Text, imgPath);
    msg = "<br>Image Uploaded Successfully";
    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + msg + "');", true);

}
else
{
    string msg2 = c.UpdateCustomer(txtcustid.Text, txtucname.Text,,null);
}
暗影行者
string Img1, unq1;
string filepath = "~/YourFolder/";
img1 = System.IO.Path.GetFileName(gridusers.SelectedRow.Cells[2].ImageName);
unq1 = filepath + img1;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章