簡體   English   中英

如何將Base64圖像轉換為文件類型

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM