0

Now I use Asp.net core as the server framework. I want to know how to upload a file to an Asp.net core server? I use web api but not the web application. So form submit is no use. The code below doesn't work.

[HttpPost("uploadImage/{accountGuid}")]
public async Task<string> UploadTargetImage(ICollection<IFormFile> files,Guid accountGuid)
{   
     if (files == null) throw new Exception("File is null");
     if (files.Count == 0) throw new Exception("File is empty");
}

I use fiddler to test the API. Like below: see the fiddler post image

The result of api is File is empty.So the server didn't get the post file. What should I do? It puzzles me for a long time.

1

1 Answer 1

1

I hava just fix it! The input name in POST must be the same as method param in ASP.NET.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.