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
chetan shinde
NA
108
45.6k
Save image using ajax method
Sep 13 2017 2:06 AM
hi all.
i am trying to save image using ajax call. but it didnt redirect to my web method. or i cant recieve image into webmethod.
here is my code.
function fileupload(name, fName) {
//var obj = {};
var obj = {};
var fl = new FormData();
var files = '';
if (name == "P")
files = $("#imgUploadPromition").get(0).files;
else
files = $("#fileUploadLogo").get(0).files;
var fileData = files[0];
// Add the uploaded image content to the form data collection
if (files.length > 0) {
//data.append("UploadedImage", files[0]);
fl.append(fName, (fileData));
//obj.append("fileName", fName);
}
else {
alert('Please Select File');
return;
}
obj.lst_to = "test";
obj.file = fl;
$.ajax({
type: 'POST',
url: "Content_New.aspx/UploadFiles",
data: JSON.stringify(obj),
cache: false,
processData: false,
contentType: false,
dataType: "json",
success: function (data) {
alert("Success!");
}
});
}
[WebMethod(EnableSession = true)]
public static string UploadFiles(string lst_to)
{
HttpPostedFile file2 = null;
if (HttpContext.Current.Request.Files.Count != 0)
file2 = HttpContext.Current.Request.Files[0];
Content_New objContent_New = new Content_New();
objContent_New.UploadFilePromotions(file2);
return "1";
}
Please help me for the same.
Reply
Answers (
2
)
Datepicker not working in my MVC4 project
WebSocket server does't connect with client on different PC