[英]How can I convert Base64 image to file type
我想将自己的网站注入ios设备,并且需要使用设备的相机。
它返回base64图像类型。 相机完成后,可以将其转换为文件类型吗?
如果移动设备返回文件路径,我可以将其重置为输入元素(使用type =“ file”),然后重用fileReader读取它吗? 怎么做?
如果移动设备返回文件路径,是否可以设置<img>
元素的src属性? 会显示吗?
您可以从客户端以base64格式获取它,并使用php将其转换为服务器端的图像文件:
function base64_convert_to_jpeg($base64_string_in, $file_out) {
$fp = fopen($file_out, "wb"); // this open file writable and binary
$data = explode(',', $base64_string_in); //explode base64 string with ',' character
fwrite($fp, base64_decode($data[1])); //decode base64 and write it to file
fclose($fp); //close the file
return $file_out; //return jpeg file
}
如果您对此有疑问或有任何疑问,请替我重播...祝您好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.