When you copy the uploaded file to wherever it's kept, you have an opportunity to fix the filename then. What you replace the spaces with is largely a matter of taste, but for example this would replace spaces with underscores (as well as copything the file to another directory:
copy($filename, 'destination/path/'.strtr(' ','_',$filename));
There's also a rename() function for renaming files.