Re: is_file and file_exists not case sensitive?
| From: | Jeffry Killen | Date: | Tue, 17 Mar 2020 18:47:02 +0000 |
| Subject: | Re: is_file and file_exists not case sensitive? | ||
| References: | 1 2 3 | Groups: | php.general php.general |
| Request: | Send a blank email to php-general+get-327061@lists.php.net to get a copy of this message | ||
> On Mar 17, 2020, at 11:08 AM, 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
Response to Both Christoph and Ashley:
My dev platform is MacOS.
I am getting the idea that case sensitivity in file names is a blessing
and a curse:
I uploaded a file named the same as an existing file but with one letter
set upper case, via FTP client, and the file system (localhost) accepted it.
I did this to see if two files with the same name accept for character case
could exist in the same directory. It WAS accepted. Then I delete the uploaded
file and tested my system. The original was not found by my testing code.
I reloaded the FTP window and the original was GONE.
I also have an upload facility programmed into my CMS system.
I tried to upload the file with the altered name and it was rejected because
the file already exists.
I also tried an on the fly script to make a file with the same name but with
an altered character case.
file_put_content(alteredFilename, '<?php?>') overwrote the existing file.
So I am getting the idea that none of the file related functions are case
sensitive.
So a file with the same name in the same location, but with case differences
could not exist as far a php is concerned.
But using FTP client to upload a test case was successful, apparently.
My FTP client is Fetch.