hello,
i am using this async file upload control to bind image without page refresh.
but it is not binding the image after upload please advice
<ajaxToolkit:AsyncFileUpload OnClientUploadComplete="uploadComplete" runat="server" ID="AsyncFileUpload1"
Width="400px" UploaderStyle="Modern" CompleteBackColor="White" UploadingBackColor="#CCFFFF"
ThrobberID="imgLoader" OnUploadedComplete="FileUploadComplete" OnClientUploadStarted = "uploadStarted" />
<asp:Image ID="imgLoader" runat="server" ImageUrl="~/images/loader.gif" /><br /><br />
<img id = "imgDisplay" alt="" src="" style = "display:none"/>
<asp:Label ID="Label1" runat="server" ></asp:Label>
<script type="text/javascript">
function uploadStarted() {
$get("imgDisplay").style.display = "none";
}
function uploadComplete(sender, args) {
var imgDisplay = $get("imgDisplay");
imgDisplay.src = "images/loader.gif";
imgDisplay.style.cssText = "";
var img = new Image();
img.onload = function () {
imgDisplay.style.cssText = "height:100px;width:100px";
imgDisplay.src = img.src;
};
img.src = "<%=ResolveUrl(UploadFolderPath) %>" + args.get_fileName();
}
</script>
protected string UploadFolderPath = "~/Uploads/";
protected void FileUploadComplete(object sender, EventArgs e)
{
string fileName = Path.GetFileName(AsyncFileUpload1.FileName);
string ext = Path.GetExtension(AsyncFileUpload1.FileName);
if (ext == ".jpg" || ext == ".jpeg" || ext == ".gif" || ext == ".png")
{
fileName = Guid.NewGuid().ToString() + ext;
}
AsyncFileUpload1.SaveAs(Server.MapPath("~/Uploads/" + fileName));
}