开发者

uploading an <img> to a remote server

开发者 https://www.devze.com 2023-02-20 13:49 出处:网络
What I am able to do right now is to get the content of a canvas and convert it to a png using img.src = toDataUrl().

What I am able to do right now is to get the content of a canvas and convert it to a png using img.src = toDataUrl().

What I would like to do now is to upload that img on a remote ser开发者_高级运维ver using PHP. Is there a way that this can be done?


Take a look at how it's done here (the second post). You need to have the cURL PHP extension installed on your web server.


Send the result of canvas.toDataURL()

var imageInfo = canvas.toDataURL(); /* sample: data:image/png;base64,iVBORw0KGgo..." */

Direct way to create the png file:

<?php
$image = fopen($imageInfo, 'r');
file_put_contents("fileName.png", $image);
fclose($image);
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号