// Upload entire file
        private void UploadWholeFile(HttpContext context, List<FileStatus> statuses)
        {
            for (int i = 0; i < context.Request.Files.Count; i++)
            {
                HttpPostedFile file = context.Request.Files[i];

                string fileName = IsIE9AndLower
                    ? file.FileName.Split(new char[] { '\\' }).Last()
                    : file.FileName;

                FileStatus status = new FileStatus(file.FileName, file.ContentLength);

                try
                {
                    string fullName = Path.Combine(StorageFolder, Path.GetFileName(fileName));
                    file.SaveAs(fullName);
                }
                catch (Exception e)
                {
                    status.error = e.Message;
                }

                statuses.Add(status);
            }
        }
        // Upload partial file
        private void UploadPartialFile(string fileName, HttpContext context, List<FileStatus> statuses)
        {
            string fullName = Path.Combine(StorageFolder, Path.GetFileName(fileName));
            FileStatus status = new FileStatus(new FileInfo(fullName));
            const int chunkSize = 1024;

            try
            {
                if (context.Request.Files.Count != 1)
                {
                    throw new HttpRequestValidationException("Attempt to upload chunked file containing more than one fragment per request");
                }

                Stream inputStream = context.Request.Files[0].InputStream;

                using (FileStream fileStream = new FileStream(fullName, FileMode.Append, FileAccess.Write))
                {
                    byte[] buffer = new byte[chunkSize];
                    int l = inputStream.Read(buffer, 0, chunkSize);

                    while ((l = inputStream.Read(buffer, 0, chunkSize)) > 0)
                    {
                        fileStream.Write(buffer, 0, l);
                    }

                    fileStream.Flush();
                }
            }
            catch (Exception e)
            {
                status.error = e.Message;
            }

            statuses.Add(status);
        }