Save Canvas on disk from clients browser?

Problem

With node-canvas (https://github.com/learnboost/node-canvas) we can save Canvas on disk.

How can we access Canvas element on client’s side from Node.js server?

  1. Client connects to Node.js server
  2. Server serves response. Client draws on Canvas
  3. Client clicks “save” and SERVER saves this Canvas to server’s disk.

Possible?

Problem courtesy of: Pono

Solution

You can get the canvas data by calling var data = canvas.toDataUrl(); This creates a data url that you could then send back to the server to save. Check out 4.8.11 The canvas element. There are a few different options you can pass along to the toDataUrl function to vary the output.

Solution courtesy of: Prescott

View additional discussion.