[英]Upload base64 string image
I have a plugin which crops my image and sends back a base64 data that looks like this: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...
. 我有一个插件可以
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...
图像并发送回如下所示的base64数据: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...
How can I upload this returned image via file upload field in my form to my server? 如何通过表单中的文件上载字段将此返回的图像上载到服务器?
PS: In short I want to automaticly add returned image to my file input field of my form. PS:简而言之,我想将返回的图像自动添加到表单的文件输入字段中。
The same way you upload any other string to your server. 将其他任何字符串上传到服务器的方式相同。 The fact that the string is Base64 doesn't change anything.
字符串为Base64的事实不会更改任何内容。
You can put it in an <input type="hidden">
, then use PHP code to decode the Base64 and save the bytes somewhere. 您可以将其放在
<input type="hidden">
,然后使用PHP代码解码Base64并将字节保存在某处。
使用此代码
$image =chunk_split( base64_encode(file_get_contents($_FILES['image_name']['tmp_name'])));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.