What are the potential pitfalls of using trim() function in PHP to handle filenames with spaces?
Using the trim() function in PHP to handle filenames with spaces can potentially remove leading or trailing spaces, but it won't remove spaces within the filename itself. To properly handle filenames with spaces, you can use the str_replace() function to replace spaces with underscores or another character of your choice.
$filename = "my file name.txt";
$filename = str_replace(' ', '_', $filename);
echo $filename; // Output: my_file_name.txt