forum

Home / DeveloperSection / Forums / Upload file using Ajax call using ASP.NET MVC

Upload file using Ajax call using ASP.NET MVC

Anonymous User350106-Mar-2014

I would like to upload a file in my page using:

<input type="file" name="FileName">

I have a button, clicking on which an ajax post is done.

$.ajax({

           cache: false,

           async: true,

           type: "POST",

           url: '@Url.Content("~/OCR/OCRProcessor")',

           data: '',

           success: function (data) {

               $('#ocrresult').val(data);

           }

       });

I would like to get the file uploaded in the controller action method something like below:

HttpPostedFileBase hpf = Request.Files["FileName"] as HttpPostedFileBase

Please let me know the optimal way to achieve this task.


Updated on 06-Mar-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By