Images don't display in the OpenCart admin file manager, possibly because of Russian letters
The output is handled by functions located in the file
filemanager.php
check whether any functions that don't support UTF-8 are used in it
set the locale setlocale(LC_ALL, "ru_RU.UTF-8");
use mb_strtolower instead of strtolower
check whether the files actually exist on the server in the folders
and whether write permission, e.g. 777, is set for these folders
I checked, the files are there, but their names are in Russian letters
even though UTF-8 is configured in Apache, the file list displays normally from the file manager, but if you do
$files = glob(rtrim($directory, '/') . '/*');
echo "
";
var_dump($files);
echo "
";
then the file names come out garbled
probably something is off with the encoding
if you replace it entirely with
$files = array();
$dir = opendir(rtrim($directory, '/').'/'.'.');
while(($currentFile = readdir($dir)) !== false){
if ( $currentFile == '.' or $currentFile == '..' ){
continue;
}
$files[] = rtrim($directory, '/').'/'.iconv('windows-1251', 'UTF-8', $currentFile);
}
then the list appears (and you have to check the extension differently)
if (is_file(iconv('UTF-8','windows-1251' , $file))) {
$ext = mb_strrchr ($file, '.');
} else {
$ext = '';
}
$ext = ".".end(explode(".", iconv('UTF-8','windows-1251' , $file)));
if (in_array(mb_strtolower($ext), $allowed)) {
$size = filesize(iconv('UTF-8','windows-1251' , $file));
but on the actual site the product photos don't display, they only display in the file manager
did you upload them via the file manager?
check which encoding the file manager used during upload?
auto or a specific one
the thing is that on a Linux system the file system itself has no encoding, and only the client, when reading and writing, tells it in which encoding to interpret file names; most likely you got a mix-up, and they weren't saved in UTF encoding, but the manager itself will read them fine, whereas the PHP scripts try to read the names by interpreting the bytes as UTF-8, while they were actually saved in, say, win-1251
you can solve the problem by setting the correct encoding
and re-uploading the files to the server
or, god forbid, rewrite the functions in the scripts themselves and shuffle the names back and forth from one encoding to another
yes, thanks, that helped
Comments