0

I have a web application C#/HTML and I must pass an image from js --> C#. The command I use is canvas.toDataURL('image/png') but the system got in crash. I use IE10.

Is there any suggest?? Thanks...

[UPDATE] Scuse me..I have a setTimeout to delay the call.When timer elapsed, the error is

Uncaught TypeError: undefined is not a function

It seams like a variable visibility. Is it possible?

salvo italy
  • 193
  • 2
  • 4
  • 14

1 Answers1

1

First you need add an input file:

<form id="submitfile" action="youraction" method="post" enctype="multipart/form-data">
  <input type="file" id="filetoup" name="file" accept="image/*" >

then you should use ajax:

$('#submitfile').ajaxForm({
complete: function(xhr) {
    alert("Upload complete");   
} 
}); 

Also you can use the way you are using

var canvasData = canvas.toDataURL("image/png");
var ajax = new XMLHttpRequest();
ajax.open("POST",'controller/action',false);
ajax.setRequestHeader('Content-Type', 'application/upload');
ajax.send(canvasData);
gon250
  • 3,405
  • 6
  • 44
  • 75
  • Scuseme I quite confuse... I have a webcam and take a screen: then I would pass the image to C#. Can you explain how? – salvo italy Mar 02 '15 at 15:57
  • Well, take a look this http://stackoverflow.com/questions/4912092/using-html5-canvas-javascript-to-take-screenshots let me know if you cant get it. – gon250 Mar 02 '15 at 16:03