Hello all,
I am working on MVC 5, I want to save image on server from input type file uploader.
Form submit,
- secondForm: function (e) {
- ar idfileTitle = document.getElementById("idfileTitle");
-
- var idfileLogo = document.getElementById("idfileLogo");
-
- var json = {};
-
- var hidvalue = $('#hdPrimUserFirstReg').val();
- var hidJson = JSON.parse(hidvalue);
-
- $.each($('#frmSubmitPremUserRegFirst').serializeArray(), function (i, field) {
- json[field.name] = field.value || '';
- });
-
- hidJson.Form2 = json;
- $formData = new FormData();
- if (idfileTitle.files.length > 0) {
- for (var i = 0; i < idfileTitle.files.length; i++) {
- $formData.append('file-' + i, idfileTitle.files[i]);
- }
- }
-
- if (idfileLogo.files.length > 0) {
- for (var i = 0; i < idfileLogo.files.length; i++) {
- $formData.append('file-' + i, idfileLogo.files[i]);
- }
- }
-
-
-
- $.ajax({
- url: '../UserRegister/PremiumUserRegistration/' + hidJson,
- type: 'POST',
- data: $formData,
- dataType: 'json',
- contentType: false,
- processData: false,
- success: function ($data) {
- $('#frmregitems').html($data);
- }
- });
Controller,
Here
pageVM
is null passing while assigning
hidJson
to
PremiumUserRegistration
action method as param.
- [HttpPost]
- public ActionResult PremiumUserRegistration(RegistrationModel pageVM)
- {
- HttpFileCollectionBase files = Request.Files;
- foreach (string fil in files)
- {
-
- }
- }
Here, Request.Files
also containing only one image details, How can get multiple images from Request.Files
?
Please help me...