problem with spaces in folder name

Hi

I’m having a bit of a problem with php and linux.
I’m using the following function, to find files with specific file extensions within a given folder and all subfolders :

function FindVideoFiles($startfolder,$specificextensions){
        $it = new RecursiveDirectoryIterator($startfolder);
        foreach( new RecursiveIteratorIterator($it) as $file) {
            if (in_array(strtoupper(substr($file, strrpos($file, '.') + 1)), $specificextensions)) {
                $files[]=array('nomedapasta'=>pathinfo($file,PATHINFO_DIRNAME));
            }
        }
        return $files;
}

$specificextensions is an array with ‘avi’,‘mkv’ and ‘mp4’ as values.
$startfolder is a string with “/mnt/HD1_4TB/refazer/A View to a Kill” as value.

When i try to run the function, it throws me an error saying “failed to open dir: No such file or directory”.
The weirdest thing is, if i change the $starfolder variable to “/mnt/HD1_4TB/refazer”, the function works and return the files inside the folder “A View to a Kill” (even with spaces in folder name).
If i rename the folder “A View to a Kill” to “AViewtoaKill” and change the $startfolder variable to “/mnt/HD1_4TB/refazer/AViewtoaKill”, the function also work…
so… i think that my problem is the spaces in the folder name.
Can someone help me on how i can solve this problem without removing the spaces in folder name ??

Thanks

Well, questions…

Is the program, meaning PHP file stored in the same folder as the images?
Is the images in the same folder as the file?

Meaning if your file-folder structure is a bunch of folders in the root folder of the server and you reach to the root, you start it with a slash. Therefore, "/mnt… first goes all the way back to the root and then into a sub-file named “mnt”… Is this file in the root folder? Or is it under the folder that the program is in? If the folder “mnt” is in the same folder as the program, just remove the leading slash.

Otherwise, give us more info about where you are storing things…

Thanks for your help, but it’s already solved.
For some reason, the space character was not chr(32).

Thanks anyway

Great!

( Sometimes that happens when I copy and paste from editor to editor… )

Sponsor our Newsletter | Privacy Policy | Terms of Service