0

I know the way to do this with PHP but does anyone know a way of doing it only with JS & HTML?

The canvas image should be saved to a server, not locally.

3
  • 1
    Send the data of your canvas to PHP in an Ajax call. Commented Sep 27, 2017 at 10:28
  • There's no way, unless your server execute JavaScript, you've tagged this with [php], though. Commented Sep 27, 2017 at 10:30
  • 2
    But, what are you gonna use backend for actually saving the image server-side.... if you only use JS / HTML you have no server access. Unless you consider node.js under your pretense Commented Sep 27, 2017 at 10:31

2 Answers 2

2

For JS in the browser security context, is not allowed to write to the user's file system Or to the server file system.

You must have a server side service that will intercept the file and than save it to the system.

to achieve it using JS only, you need to use node.js as server side

Sign up to request clarification or add additional context in comments.

1 Comment

What is node.js? Do you have any good links i can read about it?
1

Try this:

var canvas=document.getElementById("mycanvas");
var data=canvas.toDataURL("image/png");

Send the data to php in an ajax call

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.