Forums

Cyrillic characters in the file name

Sergey_2020 04 Sep, 2016
Hello!

do not register Cyrillic characters in the file name , what to do ?

Help!
GreyHead 04 Sep, 2016
Hi Sergey_2020,

You could URL encode them? What exactly is the problem that you are seeing?

Bob
Sergey_2020 04 Sep, 2016
files in which the name in Cyrillic is not recognized . Instead Cyrillic only spaces
Sergey_2020 04 Sep, 2016
so the two files in the Cyrillic alphabet did not come , only one
It is decided in such a way problem
<?php
foreach ( $files as $k => $v ) {
  if ( $v['name'] == $file_name ) {
   $i = $k+1;
   continue;
  }
}
$user = \JFactory::getUser();
return $user->username."_".rand(1, 999)."_".$file_name;
?>
Sergey_2020 04 Sep, 2016
filename:
паспорт => admin_107__.jpg
водительское => admin_147__.jpg
kopia_pasporta_1.Jpg => admin_788_kopia_pasporta_1.Jpg
Sergey_2020 05 Sep, 2016
there is such a code , but unfortunately it does not work , the error 500

<?php
function translit( $string )
{
    $converter = array(
    'а' => 'a',        'б' => 'b',        'в' => 'B',
    'г' => 'r',        'д' => 'g',        'е' => 'e',
    'ё' => 'e',        'ж' => 'zh',    'з' => 'z',
    'и' => 'i',        'й' => 'y',        'к' => 'k',
    'л' => 'l',        'м' => 'm',        'н' => 'n',
    'о' => 'o',        'п' => 'p',        'р' => 'r',
    'с' => 's',        'т' => 't',        'у' => 'u',
    'ф' => 'f',        'х' => 'h',        'ц' => 'c',
    'ч' => '4',        'ш' => 'sh',    'щ' => 'sch',
    'ь' => '',        'ы' => 'y',        'ъ' => '',
    'э' => 'e',        'ю' => 'you',    'я' => 'ya',
   
    'А' => 'A',        'Б' => 'B',        'В' => 'B',
    'Г' => 'r',        'Д' => 'g',        'Е' => 'E',
    'Ё' => 'E',        'Ж' => 'Zh',    'З' => 'Z',
    'И' => 'I',        'Й' => 'Y',        'К' => 'K',
    'Л' => 'L',        'М' => 'M',        'Н' => 'N',
    'О' => 'O',        'П' => 'P',        'Р' => 'R',
    'С' => 'S',        'Т' => 'T',        'У' => 'U',
    'Ф' => 'F',        'Х' => 'H',        'Ц' => 'C',
    'Ч' => '4',        'Ш' => 'Sh',    'Щ' => 'Sch',
    'Ь' => '',        'Ы' => 'Y',        'Ъ' => '',
    'Э' => 'E',        'Ю' => 'You',    'Я' => 'Ya',
    );
    return strtr( $string, $converter );
}
 
foreach ( $files AS $k => $v )
{
    if ( $v['name'] == $file_name )
    {
        $i = $k + 1;
        continue;
    }
}
 
$user = \JFactory::getUser();
 
return "{$user -> username}_" . rand( 1, 999 ) . '_' . translit( $file_name );
?>
Sergey_2020 05 Sep, 2016
Notice: Undefined variable: files in /home/httpd/vhosts/to54.ru/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php(148) : eval()'d code on line 32

Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/to54.ru/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php(148) : eval()'d code on line 32

Fatal error: Cannot redeclare translit() (previously declared in /home/httpd/vhosts/to54.ru/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php(148) : eval()'d code:2) in /home/httpd/vhosts/to54.ru/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php(148) : eval()'d code on line 30
GreyHead 05 Sep, 2016
Hi Sergey_2020,

The simplest solution is probably not to use the user name in the file name - if you use the ID instead then you can always look up the name.

The "Undefined variable: files" is because ChronoForms saves the file info in $form->files

The "Fatal error: Cannot redeclare translit()" can be avoided with code like this
if ( !function_exists('translit') ) {
  function translit() {
    . . .
  }
}

Bob
Sergey_2020 06 Sep, 2016
<?php
if ( !function_exists('translit') ) {
  function translit() {
    $converter = array(
    'а' => 'a',        'б' => 'b',        'в' => 'B',
    'г' => 'r',        'д' => 'g',        'е' => 'e',
    'ё' => 'e',        'ж' => 'zh',    'з' => 'z',
    'и' => 'i',        'й' => 'y',        'к' => 'k',
    'л' => 'l',        'м' => 'm',        'н' => 'n',
    'о' => 'o',        'п' => 'p',        'р' => 'r',
    'с' => 's',        'т' => 't',        'у' => 'u',
    'ф' => 'f',        'х' => 'h',        'ц' => 'c',
    'ч' => '4',        'ш' => 'sh',    'щ' => 'sch',
    'ь' => '',        'ы' => 'y',        'ъ' => '',
    'э' => 'e',        'ю' => 'you',    'я' => 'ya',
   
    'А' => 'A',        'Б' => 'B',        'В' => 'B',
    'Г' => 'r',        'Д' => 'g',        'Е' => 'E',
    'Ё' => 'E',        'Ж' => 'Zh',    'З' => 'Z',
    'И' => 'I',        'Й' => 'Y',        'К' => 'K',
    'Л' => 'L',        'М' => 'M',        'Н' => 'N',
    'О' => 'O',        'П' => 'P',        'Р' => 'R',
    'С' => 'S',        'Т' => 'T',        'У' => 'U',
    'Ф' => 'F',        'Х' => 'H',        'Ц' => 'C',
    'Ч' => '4',        'Ш' => 'Sh',    'Щ' => 'Sch',
    'Ь' => '',        'Ы' => 'Y',        'Ъ' => '',
    'Э' => 'E',        'Ю' => 'You',    'Я' => 'Ya',
    );
    return strtr( $string, $converter );
}
 }
foreach ( $files AS $k => $v )
{
    if ( $v['name'] == $file_name )
    {
        $i = $k + 1;
        continue;
    }
}
 

return rand( 1, 999 ) . '_' . translit( $file_name );
?>


Notice: Undefined variable: files in /home/httpd/vhosts/to54.ru/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php(148) : eval()'d code on line 32

Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/to54.ru/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php(148) : eval()'d code on line 32

Notice: Undefined variable: string in /home/httpd/vhosts/to54.ru/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php(148) : eval()'d code on line 29

😑
This topic is locked and no more replies can be posted.