Open uploaded file.

2 posts, 1 answers
  1. Jane
    Jane avatar
    13 posts
    Member since:
    Aug 2013

    Posted 08 Aug 2013 Link to this post

    Hi Telerik

    I am using asyncupload control to upload client files. On selecting files and uploading the names will appear on the control. So at this point I have a requirement to open the uploaded file by clicking the filename or add a button such as "View File". Please provide your valuable support.

    Thanks and Regards
  2. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Aug 2013 Link to this post

    Hi Jane,

    Please have a look into the following code I tried to open the uploaded image in a new browser tab on clicking the file name rendered below the file input. Since I am reading the file from the final upload destination, I have implemented a custom handler to upload the file on the server once they are selected.

    <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" HttpHandlerUrl="~/RadAsyncUpload/Preview/Handler.ashx"
        MultipleFileSelection="Automatic" OnClientFileUploaded="onClientFileUploaded">

    <script type="text/javascript">
        //Here you can specify the corresponding the target upload path
        var path = "http://localhost:49535/Telerik_Project/RadAsyncUpload/Uploads/";
        var $ = $telerik.$;
        function onClientFileUploaded(sender, args) {
            var row = args.get_row();
            var span = $(row).find(".ruFileWrap .ruUploadProgress");
            span.text("").append("<a target='_blank' href='" + path + args.get_fileName() + "'>" + args.get_fileName() + "</a>");

    C#: (HttpHandler)
    public class Handler : Telerik.Web.UI.AsyncUploadHandler
        protected override Telerik.Web.UI.IAsyncUploadResult Process(Telerik.Web.UI.UploadedFile file, HttpContext context, Telerik.Web.UI.IAsyncUploadConfiguration configuration, string tempFileName)
            var path = context.Server.MapPath("Uploads");
            file.SaveAs(path + "\\" + file.GetName());
            return CreateDefaultUploadResult<Telerik.Web.UI.UploadedFileInfo>(file);

  3. DevCraft R3 2016 release webinar banner
Back to Top