Re: is_file and file_exists not case sensitive?

From: Date: Tue, 17 Mar 2020 18:55:06 +0000
Subject: Re: is_file and file_exists not case sensitive?
References: 1 2 3 4  Groups: php.general php.general 
Request: Send a blank email to php-general+get-327062@lists.php.net to get a copy of this message
> On Mar 17, 2020, at 11:26 AM, Ashley Sheridan <ash@ashleysheridan.co.uk> wrote: > > > > On March 17, 2020 6:08:25 PM UTC, "Christoph M. Becker" <cmbecker69@gmx.de> > wrote: >> On 17.03.2020 at 18:40, Jeffry Killen wrote: >> >>> Hello; >>> >>> This must be the first time I have encountered this: >>> >>> I have an html interface with text input fields for >>> entering file names. The underlying javascript >>> sends and async request to verify that the file >>> exists on the server >>> >>> I have used both is_file and file_exists. >>> >>> If I use wrong case in the file name but the location/name >>> is correct both the php functions return true. >>> >>> That would indicate that they are not case >>> sensitive in matching a file name. >>> >>> How can I make them case sensitive? >>> >>> If I go to open and read or write to the >>> file and it has wrong case in the file name >>> I am expecting that the read/write or unlink, >>> or other file processing function will not work. >> >> That depends on the file system (and is not particularly related to >> PHP). Windows (NTFS) is case insensitive, Linux usually case >> sensitive, >> and AFAIK on MacOS this can be somehow configured. >> >> -- >> Christoph M. Becker > > You might be able to use the new directory iterators: > https://www.php.net/manual/en/class.recursivedirectoryiterator.php > > I've used them before, but never needed to test the case sensitivity of filenames. > Thanks, > Ash I think I could use scandir and loop through and see if there was a file name match in the target directory. Thank you for suggestion; JK

« previous php.general (#327062) next »