Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Helo Freinds

I had a doubt in what is passing from view to controller
In my controller i give like this
C#
public ActionResult Details(byte[] data)
       {
           Image g = new Image();
           g.Img = data;
           try
           {
               this.dbContext.Add(g);
               this.dbContext.SaveChanges();
           }
           catch
           {
               return View();
           }
           var str = new { st = "saved" };
           return Json(str, JsonRequestBehavior.AllowGet);
       }

In my view define <input type="file" id="photos">
by using file id am passing data.So in what format the controller received that data

My view file looks like this:
JavaScript
$("#save").click(function (event) {

              alert("hai");
              $.ajax({

                  type: "POST",
                  url: '/Home/Details',
                  data: $('#photos').load(url),
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function (str) {
                      alert("hai");
                      alert(str.st);
                  }
              });
          });


by using this syntax data:$('#photos').load(url) so in data what is there i mean path or file.In my database fields are Id(int), img(LongBlob) so my code is not working please help provide me any suggestions or code to find out the solution....
Posted
Updated 23-May-12 20:47pm
v2
Comments
Sergey Alexandrovich Kryukov 24-May-12 2:53am    
What happened? Several questions on the same topic? Whole course at some school getting identical assignments? If so, are you going to pay your money for such school? Would be sad...
--SA

1 solution

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