FileInput upload asp.net webmethod

Web Tips Q & ACategory: Krajee PluginsFileInput upload asp.net webmethod
pethum asked 2 years ago

i am using your fileinput in my asp.net website. but i need to ajax post file and other data. how can i pass fileinput into C# server webmethod.

2 Answers
Kartik Staff answered 2 years ago

You can read the POSTED FILE blob data to the server. For example in PHP it is $_FILES.
I do not have an example for ASP.NET. But an article for AJAX Uploads using FileInput plugin is mentioned for PHP example here.

markinfurkin answered 1 year ago

I successs make  work on asp.net project, but not in webmethod, i create another aspx file(with code file cs), and i make this code:

 if (Request.Files.Count > 0)
{
string path = "c:\\temp\\";
for (int i = 0; i < Request.Files.Count; i++)
{
var file = Request.Files[i];
path += file.FileName;
try
{
file.SaveAs(path);
}
catch (HttpException ex)
{
var serializer = new JavaScriptSerializer();
string jsonError = serializer.Serialize(new { error = "Error on sending files" });
Response.Write(jsonError);
}
}

Login or register to contribute or comment.

Login   Register