简体   繁体   中英

Save canvas as PNG image in specific folder with javascript

I have some graphics made with canvas that I want to save in a specific folder of the user's computer as a .png image.

I'm doing this on the client side:

$(".new_canvas").each( function(index) {

                var dataurl = $(".new_canvas")[index].toDataURL("image/png");

                $.ajax({
                        type: "POST",
                        url: "export_images",
                        data: dataurl,
                        }
                });
            });

On the server side I receive the base64 encoded string but how can I save this image in a specific directory?

I already saw some questions about this and tried a few things but with no success...

Thank you.

save in a specific folder of the user's computer

Oh dear. You absolutely cannot do this. The best you can do is present an image for download from the server, which will go into a download directory, or you can offer a link. You cannot specify where you want a file saved on a user's computer.

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