简体   繁体   English

使用javascript将画布另存为PNG图像在特定文件夹中

[英]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. 我有一些用画布制作的图形,我想以.png图像的形式保存在用户计算机的特定文件夹中。

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? 在服务器端,我收到base64编码的字符串,但是如何将该图像保存在特定目录中?

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. 您无法指定要将文件保存在用户计算机上的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM