我正在通過PHP文件從Android應用程序發送base64字符串到服務器。
我得到這個從視頻教程:
如何將base64圖像發送到服務器 - PHP
<?php
require 'Init.php';
header('Content-type : bitmap; charset=utf8');
if(isset($_POST['encoded_string'])){
$encoded_string = $_POST['encoded_string'];
$image_name = $_POST['image_name'];
$decoded_string = base64_decode($encoded_string);
$path = 'ProfileIcons/' .$image_name;
$file = fopen($path, 'wb');
$is_written = fwrite($file, $decoded_string);
fclose($file);
}
?>
它存儲在目錄中的圖片,但是當你打開,它沒有形象。這是一個空白的PNG。代碼有問題嗎?如果是這樣,我應該使用什麼?謝謝。
你能發表由 - $ encoded_string返回的字符串格式嗎?檢查你是否需要操縱它 – Inducesmile