Replace hash characters in basename

Avoids a parse error.

This bugfix brought to you by stupid Flickr users who include hashtags
in their picture titles. #badidea #breakseverything #stupidfads

Uses $wgIllegalFileChars which doesn't *actually* include the hash character.
So we have to add it.

Also changes the behaviour to use hyphens for replacements, which is
consistent with Special:Upload (not to say that's a *good* idea, but
it's better than just removing the characters...)

Change-Id: I5aa06f1e43ed2d8a4cfc326cdeb0849d6f28684f
Bug: T76038