accident Posted June 26, 2008 Share Posted June 26, 2008 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 More sharing options...
xyn Posted June 26, 2008 Share Posted June 26, 2008 cant you do something like.. <?php $url ='/path/to/file/MyFile.php' $x =strtolower($url); $f =file_get_contents($x); Link to comment https://forums.phpfreaks.com/topic/112042-case-senstive-file-exists-problem/#findComment-575141 Share on other sites More sharing options...
thebadbad Posted June 26, 2008 Share Posted June 26, 2008 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?). Link to comment https://forums.phpfreaks.com/topic/112042-case-senstive-file-exists-problem/#findComment-575151 Share on other sites More sharing options...
xyn Posted June 26, 2008 Share Posted June 26, 2008 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`) Link to comment https://forums.phpfreaks.com/topic/112042-case-senstive-file-exists-problem/#findComment-575156 Share on other sites More sharing options...
PFMaBiSmAd Posted June 26, 2008 Share Posted June 26, 2008 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. Link to comment https://forums.phpfreaks.com/topic/112042-case-senstive-file-exists-problem/#findComment-575161 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.