Telerik:
If you are monitoring this forum and theres a better way, please let me know...
When uploading an image and overwriting the old file with the same filename, and you find that the file displayed on the upload page is not refreshing, you may find this solution useful.
You may get that for 2 reasons:
1. The upload filename is the same as the previous so the browser does not refresh the image
2. The file extension changes but the page still displays the old image
The code below does 2 additional things (compared to telerik sample code)
1. It re-sets the image path after uploading (with file ext that may have changed)
2. It adds a unique query string to the end of the image source to force browser refresh
If you are monitoring this forum and theres a better way, please let me know...
When uploading an image and overwriting the old file with the same filename, and you find that the file displayed on the upload page is not refreshing, you may find this solution useful.
You may get that for 2 reasons:
1. The upload filename is the same as the previous so the browser does not refresh the image
2. The file extension changes but the page still displays the old image
The code below does 2 additional things (compared to telerik sample code)
1. It re-sets the image path after uploading (with file ext that may have changed)
2. It adds a unique query string to the end of the image source to force browser refresh
function BannerUploaded(sender, args) { var ajaxmgr = $find("<%= RadAjaxManager1.ClientID %>"); var upload = $find("<%= RadAsyncUploadBannerImage.ClientID %>"); var Extension; ajaxmgr.ajaxRequest("client1"); $telerik.$(".invalid").html(""); //Get the uploaded file ext in case the ext is different (different filename) var inputs = upload.getUploadedFiles(); for (i = inputs.length - 1; i >= 0;i--) {Extension=getFileExtension(inputs[i]);} setTimeout(function () { sender.deleteFileInputAt(0); var mySrc = document.getElementById('<%= thumbnailBanner.ClientID %>').src; var FileWOExt=removeFileExtension(mySrc); document.getElementById('<%= thumbnailBanner.ClientID %>').src=FileWOExt + '.' + Extension + "?" + new Date().getTime();}, 400); } function validationFailedBanner(sender, args) { $telerik.$(".invalid") .html("Please choose a valid image file"); sender.deleteFileInputAt(0); } function getFileExtension(filename) { return filename.split('.').pop(); } function removeFileExtension(filename) { return filename.substr(0, filename.lastIndexOf('.'));}