c# - How to send screenshot to controller? -


I'm using the html2canvas library to get a snapshot from the page, and how do I get that image in my C # Can I get into the controller?

VIEW

  $ ("#button"). Click (function () {var image; html2canvas (document.body, {onrendered: function (canvas) {image = convert convert to image (canvas); $ .post ("../../ HomeController / SetScreenshot", {sendImage : image}, function () {});}});});   

File = Request.Form ["sendImage"]. ToString (); }

Simlifting, hidden input can be omitted. This will do the trick:

  $ ("# button"). Click (function () {html2canvas (document.body, {honored: function (canvas) {var image = canvas.toDataURL ("image / PNG"); image = image. Location ('data: image / png; base 64 , '', ''); $ .ense ({type: "post", url: '../../ Home controller / saveSnapshot', data type: 'text', data: {base64data: image}, success: Function (result) {warning (result);}}}}}}   

controller (a modified version, which mapped the image Saved in folders):

  [http post] Public Activity SaveSnapshot () {bool Save = false; if (request.form ["base64data"] = null) {string image = request.form ["base64data"] .tostring (); byte [] data = convert.foambabs 64 String (image); var path = Path.Combine (Server.MapPath ("~ / upload"), "snapshot.png"); System.iof.mayleAlbets (path, data); saved = true;) Jason back ( Saved? "Picture saved": "Picture not saved");}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -