System hard drive? I do not understand the server or the client?
CUSTOMER
If you want the user to download the image automatically, you need to change the data URI scheme
Try the following:
Add to css
#myHideFrame {
position: absolute;
top: -9999px;
width: 1px;
height: 1px;
}
Add to Javascript
var img = canvas.toDataURL();
var frame = document.getElementById("myHideFrame");
if(!frame) {
frame = document.createElement("iframe");
frame.id = "myHideFrame";
document.body.appendChild(frame);
}
frame.src = img.replace(/^data[:]image\/(png|jpg|jpeg)[;]/i, "data:application/octet-stream;");
, , - ( ):
var img = canvas.toDataURL();
var link = document.createElement("a");
link.download = "photo.png";
link.href = img.replace(/^data[:]image\/(png|jpg|jpeg)[;]/i, "data:application/octet-stream;");
document.body.appendChild(link);
SERVER
, Ajax, , JQuery:
Javascript:
var img = canvas.toDataURL().replace(/^data[:]image\/(png|jpg|jpeg)[;]base64,/i, "");
$.ajax({
"type": "POST",
"url": "upload.aspx/UploadImage",
"data": {
"imageData": img
}
}).done(function(o) {
console.log(["Response:" , o]);
});
upload.aspx.cs:
...
[WebMethod()]
public static void UploadImage(string imageData)
{
string fileNameWitPath = "custom_name.png";
using (FileStream fs = new FileStream(fileNameWitPath, FileMode.Create))
{
using (BinaryWriter bw = new BinaryWriter(fs))
{
byte[] data = Convert.FromBase64String(imageData);
bw.Write(data);
bw.Close();
}
}
}
...
: http://www.dotnetfunda.com/articles/show/1662/saving-html-5-canvas-as-image-on-the-server-using-aspnet