using System.IO;
using System.Web;
using Telerik.Web.UI;

namespace RadAsyncUploadMVC
{
    public class UploadHandler : AsyncUploadHandler
    {
        protected override IAsyncUploadResult Process(UploadedFile file, HttpContext context, IAsyncUploadConfiguration configuration, string tempFileName)
        {
            // Call the base Process method to save the file to the temporary folder
            var result = base.Process(file, context, configuration, tempFileName);
            string appRoot = HttpContext.Current.Server.MapPath(configuration.TargetFolder);
            string tempName = Path.Combine(configuration.TempTargetFolder, tempFileName);
            string destName = Path.Combine(appRoot, file.FileName);

            File.Move(tempName, destName);

            return result;
        }
    }
}