[英]send image from javascript to C#
I have a web application C#/HTML and I must pass an image from js --> C#. 我有一个Web应用程序C#/ HTML,我必须从js-> C#中传递图像。 The command I use is
canvas.toDataURL('image/png')
but the system got in crash. 我使用的命令是
canvas.toDataURL('image/png')
但是系统崩溃了。 I use IE10. 我使用IE10。
Is there any suggest?? 有什么建议吗? Thanks...
谢谢...
[UPDATE] Scuse me..I have a setTimeout to delay the call.When timer elapsed, the error is [更新]打扰我..我有一个setTimeout来延迟通话。当计时器过去时,错误是
Uncaught TypeError: undefined is not a function
未捕获的TypeError:undefined不是函数
It seams like a variable visibility. 它的接缝像是可变的可见性。 Is it possible?
可能吗?
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: 那么你应该使用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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.