We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

File uploader error.

Dear all,

we want to upload just one kind of file so inside the controller we have put, this code:
private async Task UploadImageAsync(string id, string kind,
IList uploadFiles)
// TODO: thread safety.
// save in local cache the files uploaded.
if (uploadFiles.Count != 1)
return new HttpResponseMessage(HttpStatusCode.BadRequest);
// just sure of thread safety here.
var file = uploadFiles.ElementAt(0);
if (!IsValidFormat(file.ContentType))
var response = new HttpResponseMessage();
response.StatusCode = HttpStatusCode.NoContent;
response.ReasonPhrase = "Unsupported file format";
return response;
var filename = ContentDispositionHeaderValue
// mangle the file name here.
var photo = new PhotoDto();
var cachedPhoto = new PhotoDto();
photo.VehicleCode = id;
photo.Kind = kind;
using (var ms = new MemoryStream())
await file.CopyToAsync(ms);
photo.Data = ms.ToArray();
photo.Name = filename;
photo.Hash = HashFile(photo.Data);
// here we save it in the cache.
if (_cache.TryGetValue(photo.Code, out cachedPhoto))
_cache.Set(cachedPhoto.Code, photo);
_cache.Set(photo.Code, photo);
return new HttpResponseMessage(HttpStatusCode.OK);
catch (Exception e)
var httpResponse = new HttpResponseMessage(HttpStatusCode.NoContent);
httpResponse.ReasonPhrase = "File failed to upload : " + e.Message;
return httpResponse;
But ui says always is successful uploaded in ejs-upload. Any hints?

1 Reply

PO Prince Oliver Syncfusion Team July 17, 2019 06:59 AM UTC

Hi Giorgio,      

Thank you for contacting us.   

On the client side, we have shown the upload status based on the server status code. If the status code is between 204-299 then we consider it to be successful. So, kindly set the status code above 300 for BadRequest and to notify the error.   

Let us know if you need any further assistance on this.   


Live Chat Icon For mobile
Up arrow icon