I want to inject my site to ios device and I need to use the device's camera.
我想将我的网站注入ios设备,我需要使用设备的相机。
It returns a base64 image type. When the camera is finished, can I convert that to a file type?
它返回base64图像类型。相机完成后,我可以将其转换为文件类型吗?
If mobile device return a file path, can I reset it to a input element (with type="file") and then reuse fileReader to read it? How to do it?
如果移动设备返回文件路径,我可以将其重置为输入元素(type =“file”)然后重复使用fileReader来读取它吗?怎么做?
If mobile device return a file path, can I set the <img>
element's src attribute? will it show?
如果移动设备返回文件路径,我可以设置元素的src属性吗?它会显示吗?
1 个解决方案
#1
0
you can get it from client in base64 format and the convert it to image file in server side using php:
你可以从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
}
if you have problem with it or you have any question about that, replay that for me... good luck
如果你有问题或者你对此有任何疑问,请为我重播...祝你好运
#1
0
you can get it from client in base64 format and the convert it to image file in server side using php:
你可以从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
}
if you have problem with it or you have any question about that, replay that for me... good luck
如果你有问题或者你对此有任何疑问,请为我重播...祝你好运