PHP Upload - Spaces in File Name
问题 When I use my upload script to upload a PHP file, I can't upload a file with spaces in it (I get a 500 error). Is there a way so my code automatically puts an underscore in the file name instead of the space? All help is greatly appreciated. :) 回答1: Simply use str_replace to replace all white spaces with another string: $fileName = str_replace(" ", "_", $fileName); Doc: php.net 回答2: Use this regular expression.suppose your filename look like my pic.jpg (one spaces) or my pic.jpg (three spaces