简体   繁体   中英

send image to server by passing datURL generated from canvas

I tried to save canvas image to '~/image/upload' folder in my application. I get this error: Failed to load resource: the server responded with a status of 405 (Method Not Allowed). What am I doing wrong here?

var dataURL = canvas.toDataURL();
$.ajax({
type: "POST",
url: "image/upload",
data: { 
        imgBase64: dataURL
    }
}).done(function(o) {
   console.log('saved');                                                                     
});

可能需要转义网址

var dataURL = encodeURIComponent(canvas.toDataUrl());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM