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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

File uploader error.

Thread ID:





145981 Jul 16,2019 03:15 PM UTC Jul 17,2019 06:59 AM UTC ASP.NET Core - EJ 2 1
Tags: File Upload
Asked On July 16, 2019 03:15 PM UTC

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?

Prince Oliver [Syncfusion]
Replied On 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.   



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon