This is a migrated thread and some comments may be shown as answers.

AsyncUpload_FileUploaded preview for <img />?

0 Answers 39 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 02 Sep 2016, 08:40 PM

Hi All,

Reason why I wanted to preview it with img tag for I have a special CSS that is attached to it (I have no issue when I preview it with RadImageEditor).

<script type="text/javascript">
    var imageUploaded = false;
    function OnClientFilesUploaded(sender, args) {
      $find('<%=RadAjaxManager1.ClientID %>').ajaxRequest();
      imageUploaded = true;
  }
</script>

 

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnablePageHeadUpdate="false">
  <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
      <UpdatedControls>
         <telerik:AjaxUpdatedControl ControlID="imgProfile" />
      </UpdatedControls>
    </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

 

<img id="imgProfile" runat="server" alt="Profile" src="..\default.jpg" />
<telerik:RadAsyncUpload ID="AsyncUpload1" runat="server"
  OnClientFilesUploaded="OnClientFilesUploaded"    
  OnFileUploaded="AsyncUpload1_FileUploaded"
  MaxFileSize="1024000" AllowedFileExtensions="jpg,png,gif,bmp"
  AutoAddFileInputs="false" Localization-Select="Upload" />

Protected Sub AsyncUpload1_FileUploaded(sender As Object, e As FileUploadedEventArgs)
 
        Using stream As Stream = e.File.InputStream
            Dim imgData As Byte() = New Byte(stream.Length - 1) {}
            stream.Read(imgData, 0, imgData.Length)
            Dim ms As New MemoryStream()
            ms.Write(imgData, 0, imgData.Length)
            Context.Cache.Insert(Session.SessionID + "UploadedFile", ms, Nothing, DateTime.Now.AddMinutes(20), TimeSpan.Zero)
        End Using
 
''Code for updating Img src???
        
    End Sub

 

I did try to save first the file to a folder and then use the path for the img src but its not reflecting. I still need to do refresh just to make my img update its image.

I hope anyone can suggest for better solution.

 

Thanks in advance,

RJ

No answers yet. Maybe you can help?

Tags
AsyncUpload
Asked by
RJ
Top achievements
Rank 1
Share this question
or