Re: file_Exists() and case

From: Date: Sun, 23 Nov 2008 17:24:17 +0000
Subject: Re: file_Exists() and case
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-283721@lists.php.net to get a copy of this message
Stan wrote:
If $basePicture = "../pictures/2008 west coast trip/2008-06-10 first week at Chris'/DSC_0011.jpg" and the file actually is "../pictures/2008 west coast trip/2008-06-10 first week at Chris'/DSC_0011.JPG" (uppercase extension) the following snippet of code ---------------------------------------------------------------------------- ----------------------- /* make sure the picture file actually exists */ if(!file_Exists($basePicture)) { echo "file = '" . $basePicture . "' doesn't exist.<br>\n"; $extStartsAt = strrpos($basePicture, ".") + 1; $extOfBasePicture = substr($basePicture, $extStartsAt); $basePicture = substr_replace($extOfBasePicture,strtoupper($extOfBasePicture),$extStartsAt) ; } else { echo "file = \"" . $basePicture . "\" exists.<br>\n"; } ---------------------------------------------------------------------------- ----------------------- generates ---------------------------------------------------------------------------- ----------------------- file = "../pictures/2008 west coast trip/2008-06-10 first week at Chris'/DSC_0011.jpg" exists. ---------------------------------------------------------------------------- ----------------------- The script is running on an UBUNTU v8.04 LAMP server. Case is supposed to matter, isn't it? Thanks, Stan Yes, case matters, but only of the file name, not the extension (I think). The extension is simply a secondary file-type identifier.
.jpg = .JPG = .jPg I could be wrong. - Craige

« previous php.general (#283721) next »