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 File = Request.Form ["sendImage"]. ToString (); } Simlifting, hidden input can be omitted. This will do the trick: controller (a modified version, which mapped the image Saved in folders):
$ ("#button"). Click (function () {var image; html2canvas (document.body, {onrendered: function (canvas) {image = convert convert to image (canvas); $ .post ("../../ HomeController / SetScreenshot", {sendImage : image}, function () {});}});});
$ ("# 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);}}}}}}
[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
Post a Comment