POST file list to controller in ajax post

I tried to upload documents but I couldnt pass to list my controllers parameter. My scenario is:

  1. user click to "choose file" button and pick the files and press done
  2. then my some functions get file list and pass to controller for save locally via POST merhod like below:

view side: (get file list)

   function saveDocuments(documentList) {
        if (documentList.length > 0)
        {
            var formList = new Array;
            for (var i = 0; i < documentList.length; i++) {
                var form = new FormData();
                var file = documentList[i];

                form.append('FormFile', file);
                formList.push(form);
                }
                 savePhysicalFile(formList);
              }
         }

view side: (post file list)

 function savePhysicalFile(formData)
    {
        if (formData != null)
        {
            $.ajax({
                url: "Installation/SavePhysicalPath",
                type: 'POST',
                dataType: "json",
                contentType: "multipart/form-data",
                data:formData,
                processData: false,
                contentType: false,
                success: function (result) {
                    console.log("Success", result);
                },
                error: function (data) {
                    console.log(data);
                }
            });
        }
    }

In my controller side; the parameter "model" is always null. I couldnt pass view side list here. How can I figure out ?

controller side

public JsonResult SavePhysicalPath([FromForm] List<FileModel> model)
        {
            var savingRootPath = @"C:\MyDocuments";

            //I'm doing save locally
           
            return Json(savingRootPath);
        }

model side

    public class FileModel
    {
        public string Files { get; set; }

        public IFormFile FormFile { get; set; }
    }

163 thoughts on “POST file list to controller in ajax post”

  1. Pingback: debviagrals
  2. Pingback: buy viagra
  3. Pingback: cheapest viagra
  4. Pingback: cialis europe
  5. Pingback: viagra price
  6. Pingback: cialis 24 hours
  7. Pingback: cheap cialis
  8. Pingback: viagra cost 2017
  9. Pingback: tadalafil pricing
  10. Pingback: le tadalafil
  11. Pingback: sildenafil cost
  12. Pingback: viagra
  13. Pingback: sildenafilo
  14. Pingback: viagra cvs
  15. Pingback: women take viagra
  16. Pingback: viagra in india
  17. Pingback: herb viagra
  18. Pingback: viagra for women
  19. Pingback: sildenafil price
  20. Pingback: viagra amazon
  21. Pingback: cialis best price

Leave a Comment