A simple regexp will do the trick:
if (preg_match("/[.\'_-a-zA-Z0-9]+$/",$filename))
{
filename is ok
}
else
{
#filename is not ok
};
Mind you, that check will not happen untill the file has been uploaded and that's waaaaay too late.
I suggest you accept the file, store the 'uploaded' name somewhere, and use your own 'random' name to save the file, and then start checking the filename.
If the name is ok, rename the uploaded file to the real name. If not, you can ask the uploaded to enter a new name, without having to upload the file again.