Base64 decoded image is corrupted when sending to S3 bucket

I have a base64 image and I will send it to amazon S3 but when it is uploaded the jpeg is 0kb in size and it is corrupted.
by the way I am using AWS SDK for PHP.

Here is my PHP code:


`<?php
include ‘multi-step/connection.php’;
require ‘../vendor/autoload.php’;

$image = $_POST['image'];
$studentID = date("Y"). '-' .mt_rand();

$image_parts = explode(";base64,", $image);
$image_type_aux = explode("image/", $image_parts[0]);
$image_type = $image_type_aux[1];
$image_base64 = $image_parts[1];

$decodedImage = base64_decode($image_base64);


$args = [
    'credentials' => [
        'key' => '<KEY>',
        'secret' => '<SECRET KEY>',
    ],
    'region' => 'ap-southeast-1',
    'version' => 'latest'
];

use AwsS3S3Client;

try{

$sdk = new AwsSdk($args); /*Instantiate SDK class with configs for API use*/

$s3Client = $sdk->createS3(); /*creates the S3 Client for API use*/

$key = 'i-attend-faces/' .$studentID. '/facereference.jpeg';

/*print_r($_FILES['file']);*/
$result = $s3Client->putObject([
    'Bucket' => 'iattendfacebucket',
    'Key' => $key,
    'Body' => $decodedImage,
    'ContentType'=> 'image/jpeg',
]);
echo "FILE SENT";
echo $result;
}catch(Exception $e){
echo $e;
}`

I tried decoding it and then place it in the Body but it is also corrupted.