This should be the PHP file that you need.
It worked for me, make sure you have a folder where the PHP file sits named "user_photo", or change the directory name.
$img = $_POST['photo'];
$img = str_replace('data:image/jpeg;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.jpeg';
$success = file_put_contents($file, $data);
I tried out your code, unfortunately also resulting a blank JPEG.
I made a sample .capx of what I've done, so if you have time to check it out, that would be awesome.
Links for my server:
photo directory: aalic1nrf.3owl.com/licagr-photos
The PHP code is the exact same as you posted, except I changed the directory folder.
By going to /upload.php it actually says;
Warning: chdir(): open_basedir restriction in effect. File() is not within the allowed path(s): (/home/u393737372:/usr/lib/php:/tmp) in /home/u393737372/public_html/upload.php on line 3
I guess that does not matter since it's just a warning?
.CAPX download: mediafire.com/download/2m5of2be0gvflba/snapshot.capx