TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhilash J A
533
2.4k
598k
how multiple file upload in jquery ajax submit?
Mar 28 2017 4:09 AM
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"
);
/*This fileuploader Id*/
var
idfileLogo = document.getElementById(
"idfileLogo"
);
/*This fileuploader Id*/
var
json = {};
var
hidvalue = $(
'#hdPrimUserFirstReg'
).val();
/*This is the hiddenfield Id*/
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]);
}
}
/*Here 'hidJson' containing all form data*/
$.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...
Reply
Answers (
1
)
Queried data from Controller to Partial View
How to make a grdview field value a link -Anchor link