繁体   English   中英

获取要上传的图片的路径

[英]Get path of image to fileupload

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

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

 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;

暂无
暂无

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

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