2016-08-04 71 views

回答

2

的base64編碼包含「數據:圖像/ PNG;的base64」只是將其刪除,然後嘗試解碼,即使它不工作,然後將其替換空格「+」和解碼

$filename_path = md5(time().uniqid()).".jpg"; 
$base64_string = str_replace('data:image/png;base64,', '', $base64_string); 
$base64_string = str_replace(' ', '+', $base64_string); 
$decoded = base64_decode($base64_string); 
file_put_contents("uploads/".$filename_path,$decoded); 
+1

謝謝,這對我有用。 –