Jump to content

Case senstive file exists problem


accident

Recommended Posts

Hello, I migrated my PHP install to a new linux ubuntu samba server (previous was just a debian server), in the process I also upgraded from version 4 to version 5.

Anyways, I have a script that checks if a file exists, then reads from the file. This script always used to work fine but now have a problem.

 

I have all filenames stored in a database lower case.

when I do a check to see if a file exists, it says it exists, but then when I try to read from the file, I get an error thrown saying the file doesnt exist.

I have narrowed down the issue to be that the file_exists seems to be case insenstive but file_get_contents does seem to be case senstive. Anyway to resolve this error? I know of a few ways I could do this (such as get a directory listing of all the files, and create a map between the lower case file names and real case file names). But wondering if there is another way to solve this issue since this could pose a problem in other scripts to

 

Link to comment
https://forums.phpfreaks.com/topic/112042-case-senstive-file-exists-problem/
Share on other sites

You could rename() the files to all lowercase if possible, and then in the future only use lowercase filenames (what I do - simply the best solution :)). That, or just save the case-sensitive filenames in the DB to start with (I know that's a bit late now, but maybe you can recreate the DB?).

or just save the case-sensitive filenames in the DB to start with (I know that's a bit late now, but maybe you can recreate the DB?).

 

taking this solution is simple and fast if you do this...

 

 

Query:

update `your_table` set `file_name` =lcase(`file_name`)

I would just rename all your files to the lowercase names that are stored in the database.

 

Find if there is an existing php bug report about this. If there is, add your own symptoms to it or if there is not an existing php bug report create one.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.