上传后显示图片

时间:2014-10-29 17:14:26

标签: asp.net asyncfileupload

我在上传后没有刷新页面使用这篇文章来显示图片 Display image after upload without page refresh or postback using ASP.Net AsyncFileUpload Control
我自定义了FileUploadComplete,因为我想为上传的文件创建名称:

protected void FileUploadComplete(object sender, EventArgs e)
{
    string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
    filename = Uploader.CreateNameForFile(filename);
    AsyncFileUpload1.SaveAs(Server.MapPath(this.UploadFolderPath) + filename);
    Session["image"] = filename;
}

更改代码后,上传后图片无法显示 我该怎么办?

1 个答案:

答案 0 :(得分:0)

你必须拥有这个场景的javascript:

来自背后的代码

url =已保存图片的位置

ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "image", "top.$get(""" & _img.ClientID & """).src = '" & url & "';", True)

Display image after upload without page refresh or postback using ASP.Net AsyncFileUpload Control 向您展示如何从客户端

进行操作