Skip to content
Loading
  
  •     
      
  •         "submit" value="Submit" />  
  •       
  •   
  •  
    API is 
    1. public class UploadController : ApiController  
    2. {  
    3.     public async Task PostFormData()  
    4.     {  
    5.         // Check if the request contains multipart/form-data.  
    6.         if (!Request.Content.IsMimeMultipartContent())  
    7.         {  
    8.             throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);  
    9.         }  
    10.   
    11.         string root = HttpContext.Current.Server.MapPath("~/App_Data");  
    12.         var provider = new MultipartFormDataStreamProvider(root);  
    13.   
    14.         try  
    15.         {  
    16.             // Read the form data.  
    17.             await Request.Content.ReadAsMultipartAsync(provider);  
    18.   
    19.             // This illustrates how to get the file names.  
    20.             foreach (MultipartFileData file in provider.FileData)  
    21.             {  
    22.                 Trace.WriteLine(file.Headers.ContentDisposition.FileName);  
    23.                 Trace.WriteLine("Server file path: " + file.LocalFileName);  
    24.             }  
    25.             return Request.CreateResponse(HttpStatusCode.OK);  
    26.         }  
    27.         catch (System.Exception e)  
    28.         {  
    29.             return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e);  
    30.         }  
    31.     }  
    32.   
    33. }  
     you can now use Postman instead of Html. API will be same.
    +1
  • Rijwan Ansari
    +1
    enter image description here
    You can choose file option to send image as shown
     
    +1