Skip to content

how to read files with spaces and special characters in their name?

i have lots of videos in my server and i use the following code to get the duration of the video and it works fine..

        passthru("ffmpeg -i ".$srcfile." 2>&1");
        $duration = ob_get_contents();

But i could not get the duration for the files which has a space or any special characters like ( ‘ # % etc…

I cant rename the files as it is stored already and the names of those files are also stored in db and it would take a toll to change all in a live site..

So is there any method for accessing/reading the files with special characters?




Incidentally, you should always use this for any shell arguments, less you want to make your application open to shell injection-attacks, which could be very dangerous.

7 People found this is helpful