私はbase64形式の画像をアップロードする必要があるApiを作成しました。 大きな画像(820 KB)をBase64形式でアップロードしようとすると表示されます 500内部サーバーエラー&小さな画像(16 KB)をアップロードしようとすると、 が正常にアップロードされました。また、サーバーのアップロードサイズの制限を確認しました。 64MBです。大きなbase64はアップロードされませんイメージ文字列。 以下は私のjsonリクエストとapiのPHPコードです。大きな画像はBase64のサーバーでphpを使用してアップロードされていません
PHPコードの下
<?php
$jsonreq = $app->request->getBody();
$encodedata = json_decode($jsonreq, true);
$userid = !empty($encodedata['userid']) ? $encodedata['userid'] : '';
$goal = !empty($encodedata['goal']) ? $encodedata['goal'] : '';
$title = !empty($encodedata['title']) ? addslashes($encodedata['title']) : '';
$category = !empty($encodedata['category']) ? $encodedata['category'] : '';
$story = !empty($encodedata['story']) ? $encodedata['story'] : '';
$image = !empty($encodedata['photo']) ? $encodedata['photo'] : '';
$db = getDB();
$sql = "SELECT * FROM users where id='" . $userid . "'";
$stmt = $db->query($sql);
$obj = new stdClass();
if ($stmt->rowCount() > 0) {
if ($image != "" || $image != NULL) {
$users = $stmt->fetch(PDO::FETCH_OBJ);
$img = str_replace('data:image/png;base64,', '', $image);
$img = str_replace(' ', '+', $img);
$fileName = uploadBase64Image($userid, $img, uploadFundraiserImage);
$imagepath = uploadFundraiserImage . $fileName;
$imagepath = str_replace('../', '', $imagepath);
} else {
$imagepath = '';
}
?>
私のJSON要求
{
"goal":22,
"title":"test new2",
"story":"test new2",
"category":"health",
"userid":"46",
"photo":"here we paste base64 image string"
}
たちは、たとえば、大きな画像を取る場合、私のIMGEサイズは以下のbase64文字列のための800キロバイトである、それは500内部サーバーを示した。ここで私はbas64文字列を貼り付けることができません。かなり長いためですが、800kb以上のイメージを取ると次のエラーが表示されます。
500 Internal Server Error
Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
この問題を解決するのを手伝ってください。
php.iniで「max_post_size」をチェックしましたか? –
はいそれはまた65Mです。 –
サーバのエラーログを確認します。通常は/var/log/apache2/error.logです。 –