Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET MySQL MVC3
Helo Freinds
 
I had a doubt in what is passing from view to controller
In my controller i give like this
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:
 $("#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 23-May-12 20:19pm
Edited 23-May-12 20:47pm
v2
Comments
SAKryukov at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 503
1 George Jonsson 311
2 CPallini 290
3 OriginalGriff 139
4 Prasad Khandekar 135
0 OriginalGriff 4,623
1 CPallini 3,410
2 Sergey Alexandrovich Kryukov 2,929
3 George Jonsson 2,319
4 Gihan Liyanage 2,077


Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 24 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100