The key shouldn't have a path in it at all, but it could be a directory since you don't specify it should be for files only. Its not recursive, so it will only have the current level.
%3C is a < character. That cannot come from reading the filenames as < is an illegal character in a filename. If I recall linux will accept < and > in its filename, but should be avoided. It is unlikely this is the case here.
The HTML you have is invalid. This is malformed:
<img src=./content/uploaded/" . $key . "</a>. You have to change the <img> to be single sided, and the entire <img/> tag can be wrapped with an anchor, but you cannot have an anchor as a part of the attribute in the source as you have it now. That should be using
'<img src="./content/uploaded/' . $key . '" alt=""/>' and can be wrapped with the anchor if desired. You'll need to add additional code to pull out just files though, this one will let you follow directories as well.