upload($_FILES[$file]); if ($id) { echo '{"status":"success", "id":"'.$id.'"}'; exit; } else { echo '{"status":"error", "code":"Uplodad error id: '.$id.'"}'; exit; } } echo '{"status":"error", "code":"Other error"}'; exit; ?>