My code works fine in Android, but doesn't work in HTML5
File upload.php
<?php
//chdir('');
$img = $_POST['photo'];
define('UPLOAD_DIR', 'user_photo/');
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
echo $file;
?>