Looks alright at a glance, can you tell us more about your problem? Do you get errors, or does the rewrite simply never happen?
Also, consider using a basepath in your rewrite blocks, as Caddy will check this first and avoid unnecessary regex (a big resource drain). Like the following untested example:
rewrite /uploaded {
r ^uploaded/(\w+)/?$
to uploaded.php?filecode={1}
}
Had a further look into this, my advice was a little off re: basepath, as using the basepath removes this from the regex string. Instead, I have successfully tested with this Caddyfile: