Save canvas dataurl to user's file system

Okay, so, I have a MVC app where I'm creating a canvas image, and getting the data url just by doing canvas.toDataURL("image/png"). What I'd like to do is save this to the user's file system. I tried doing it just with javascript by doing: var saveUrl = canvas.toDataURL("image/png"); saveUrl = saveUrl.replace("image/png", "application/octet"); window.open(saveUrl); But that just gives me a file named `download` without any extension or anything. I'd like to get the save dialog and give the file a type and name, and save that to the user's disc. So I figured I could post the data to the server, and then do something with the response headers to tell the browser that I'm trying to save an image for it, but I can't find a good way to do this. I'm using ASP.NET MVC. Does anyone have a good easy way for me to do this?

以上就是Save canvas dataurl to user's file system的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏