window.base64 = {
ABC: [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '=',
],
fromBuffer(input) {
const bytes = new Uint8Array(input);
const chars = new Array(Math.ceil(bytes.length * 4 / 3));
for (let targetIdx = 0, sourceIdx = 0; sourceIdx < bytes.length; sourceIdx += 3) {
const [ byte1, byte2, byte3, ] = bytes.subarray(sourceIdx, sourceIdx + 3);
const haveByte2 = Number.isInteger(byte2);
const haveByte3 = haveByte2 && Number.isInteger(byte3);
chars[targetIdx++] = this.ABC[byte1 >> 2 & 0x3F];
chars[targetIdx++] = this.ABC[byte1 << 4 & 0x30 | (haveByte2 ? byte2 >> 4 & 0x0F : 0)];
chars[targetIdx++] = this.ABC[haveByte2 ? byte2 << 2 & 0x3C | (haveByte3 ? byte3 >> 6 & 0x03 : 0) : 64];
chars[targetIdx++] = this.ABC[haveByte3 ? byte3 << 0 & 0x3F : 64];
}
return chars.join('');
},
toBuffer(input) {
const chars = input.replace(/[^A-Za-z0-9\+\/]/g, '');
const bytes = new Uint8Array(Math.floor(chars.length * 3 / 4));
for (let targetIdx = 0, sourceIdx = 0; sourceIdx < chars.length; sourceIdx += 4) {
const [ char1, char2, char3, char4, ] = Array.from(chars.substring(sourceIdx, sourceIdx + 4), item => this.ABC.indexOf(item));
const haveChar3 = Number.isInteger(char3);
const haveChar4 = haveChar3 && Number.isInteger(char4);
bytes[targetIdx++] = char1 << 2 & 0xFC | char2 >> 4 & 0x03;
if (haveChar3) bytes[targetIdx++] = char2 << 4 & 0xF0 | char3 >> 2 & 0x0F;
if (haveChar4) bytes[targetIdx++] = char3 << 6 & 0xC0 | char4 >> 0 & 0x3F;
}
return bytes.buffer;
},
};
conn.send(document.querySelector('#sendMessasgeFile').files[0])
This - в функции, которая передана в слушатель - равна элементу, на который этот слушатель повесиили
When attaching a handler function to an element using addEventListener(), the value of this inside the handler will be a reference to the element. It will be the same as the value of the currentTarget property of the event argument that is passed to the handler.
/
а не /index.html
root@node3:~# apt list php7.4*mysql*
Listing... Done
php7.4-mysql-dbgsym/bookworm 1:7.4.33-8+0~20230904.88+debian12~1.gbp87c414 amd64
php7.4-mysql/bookworm 1:7.4.33-8+0~20230904.88+debian12~1.gbp87c414 amd64
root@node3:~# dpkg -L php8.1-mysql | grep .so
/usr/lib/php/20210902/mysqli.so
/usr/lib/php/20210902/mysqlnd.so
/usr/lib/php/20210902/pdo_mysql.so
root@node3:~#