Имя загружаемого файла на кириллице

3

Добрый вечер!
Загрузил файл с именем на кириллице пасхальные_яйца.jpg. После загрузки вижу его с именем file:/pashal'nye_ajca.jpg
Я думал что проблема с мягким знаком и унылым транслитом решена в 6 версии с переходом на юникод и вот ... такая досада.
Есть ли простое решение или придётся загружать файлы только с английским именем?

Comments

  1. Re: Имя загружаемого файла на кириллице

    The clipboard.js library, while once popular for enabling copy-to-clipboard functionality without Flash, is now considered outdated due to the evolution of modern web APIs and lack of active maintenance. Fixed token selector issue when starting with a unescaped number by adding a cb- prefix.

    Guess the clipboard.js should replaced with the modern Clipboard API.
    /**
    * Native Clipboard API using data-clipboard-target attribute
    * Just like the popular Clipboard.js library, but 100% vanilla JS
    */
    document.addEventListener('DOMContentLoaded', () => {
     
        // Find ALL buttons that have the data-clipboard-target attribute
        const copyButtons = document.querySelectorAll('button[data-clipboard-target]');
     
        copyButtons.forEach(button => {
     
            button.addEventListener('click', async (event) => {
                event.preventDefault();
     
                // Get the target selector (e.g. "#token-pre")
                const targetSelector = button.getAttribute('data-clipboard-target');
     
                // Find the element to copy from
                const targetElement = document.querySelector(targetSelector);
     
                if (!targetElement) {
                    console.error(`Target element "${targetSelector}" not found!`);
                    return;
                }
     
                // Get the text to copy
                let textToCopy = '';
     
                // Smart detection: use .value for form elements, .textContent for everything else
                if (targetElement.tagName === 'TEXTAREA' || targetElement.tagName === 'INPUT') {
                    textToCopy = targetElement.value.trim();
                } else {
                    textToCopy = targetElement.textContent.trim();
                }
     
                // If there's nothing to copy, do nothing
                if (!textToCopy) {
                    console.warn('Nothing to copy – text is empty');
                    return;
                }
     
                try {
                    // The modern Clipboard API
                    await navigator.clipboard.writeText(textToCopy);
     
                    // Visual feedback
                    const originalText = button.innerHTML;
     
                    button.classList.add('copied');
                    button.innerHTML = `✅ Copied!`;
     
                    // Reset button after 2 seconds
                    setTimeout(() => {
                    button.classList.remove('copied');
                    button.innerHTML = originalText;
                    }, 2000);
     
                    console.log('✅ Copied to clipboard:', textToCopy.substring(0, 30) + '...');
     
                } catch (err) {
                    console.error('Failed to copy using Clipboard API:', err);
     
                    // Fallback message
                    const originalText = button.innerHTML;
                    button.style.background = '#ef4444';
                    button.innerHTML = `❌ Failed`;
     
                    setTimeout(() => {
                        button.style.background = '';
                        button.innerHTML = originalText;
                    }, 2000);
                }
            });
        });
     
        console.log('Clipboard API ready!');
    });
    • WikiAdmin
    • 04/05/2026 22:43 edited
Log in or create an account to post a comment.