最好添加一个Button按钮,点击该按钮即可将FileUpLoad选择的图片显示在Image控件上;
代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string filename = FileUpload1.FileName;
string uploadfilename = Server.MapPath("~/") + filename;
FileUpload1.PostedFile.SaveAs(uploadfilename);
Image1.ImageUrl = uploadfilename;
}
}
FileUpLoadl里面写属性
在FileUpLoad读到图片的路径就给image 就可以了
function selectimage(imageurl)
{
var imageview=document.getElementById("imageview");
imageview.style.display="block";
imageview.src=imageurl.value;
}