I am currently displaying the file name from the database on my PHP page. However, some file names on the server's folders have a different case. So the database may say image1.jpg and the file name on the server may say "image1.JPG" in upper case. This is random with some of the files. These files do not get displayed. Is there a way that I can use a function so that it can be displayed. We are talking about more than 1000 files here. So any help would be highly appreciated.
You can store the full image in the Database table by converting it into the base64 format. You don't need to store image reference in the Database table e.g. name, path, and not require to store the image on your server. In PHP base64_encode() method is been used for base64 conversion.
Right-click that file to open a context menu and then select "Properties." The Properties dialog box opens on the computer. The file name of the picture in question is listed to the right of Name.
yes, we compile a java file with a different name than the class, provided that there should not be any public class in that file. If there is any public class in file then in that case you have to give that name as file name. But if your class does not contain any public class then you can give any name to you class.
Paths include the root, the filename, or both. That is, paths can be formed by adding either the root, filename, or both, to a directory.
I would run a custom file_exists() function to check for which case the image's extension is.
Use this custom function to check for the correct case (pass it lowercase, then use lowercase if it returns a 1, or use uppercase if it returns a 2):
function file_exists_case($strUrl)
{
$realPath = str_replace('\\','/',realpath($strUrl));
if(file_exists($strUrl) && $realPath == $strUrl)
{
return 1; //File exists, with correct case
}
elseif(file_exists($realPath))
{
return 2; //File exists, but wrong case
}
else
{
return 0; //File does not exist
}
}
You really should go in and make all your file name extensions lowercase when you get the time, though.
The way you would do that is by running a glob() through the directories: http://php.net/manual/en/function.glob.php and renaming every file extension to lowercase using strtolower(): http://php.net/manual/en/function.strtolower.php
Not sure if converting the extensions to lowercase is an option. But if there are no other systems that depend on certain extensions to be capitalized then you could run something like this:
find . -name '*.*' -exec sh -c '
a=$(echo {} | sed -r "s/([^.]*)\$/\L\1/");
[ "$a" != "{}" ] && mv "{}" "$a" ' \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With