Reputation: 193
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?
Upvotes: 0
Views: 1240
Reputation: 3545
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);
Upvotes: 1