Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i want to save file or image to a server but using ajax function feature can i do that pls suggest me.
Posted
Updated 16-Dec-15 19:51pm
v3

1 solution

 
Share this answer
 
Comments
jiwade 17-Dec-15 2:30am    
Thanks bro !
both links for php

pls refer my code

$('#clickss').click(function () {
var data = new FormData();

var files = $("#filetest").get(0).files;
// Add the uploaded image content to the form data collection
if (files.length > 0) {
data.append("UploadedImage", files[0]);
}
$.ajax({
url: "DIndex.aspx/savefile",
type: "POST",
contentType: false,
processData: false,
// dataType: "json",
data: data,
success: function (data, textStatus, jqXHR) {
alert("done");
},
error: function (xhr, ajaxOptions, thrownError) { }
});

});
and
server side

[WebMethod]
[WebMethod]
public static void savefile()
{

var filename= HttpContext.Current.Request.Files[0];
}
but perform done but not travel to server function
Praveen Raghuvanshi 17-Dec-15 2:58am    
Any error you are getting.
check this https://cmatskas.com/upload-files-in-asp-net-mvc-with-javascript-and-c/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900