uvdesk / community-skeleton

UVdesk Opensource Community Helpdesk Project built for all to make a Full Ticketing Support System along with many more other features.
https://www.uvdesk.com
MIT License
7.18k stars 448 forks source link

access to upload file data #632

Closed Evgl1 closed 1 year ago

Evgl1 commented 1 year ago

Hello. Can you please tell me how can I access the binary data of the uploaded file? /var/www/html/helpdesk-vc/vendor/uvdesk/core-framework/Resources/views/Templates/attachment.html.twig

    **if (fileName.startsWith('Загрузка ПСЦ')) {
        alert(fileName)
        f = files[i]
        data = f.arrayBuffer()
        workbook = XLSX.read(data)
    }**
for (var i = 0; i < files.length; i++) {
    var fileName = files[i].name;

    if (files[i].size > this.upload_max_filesize) {
        isError = true;
        break;
    }

    // Validating Form Size
    var formSize = 0
    var formData = new FormData(currentElement.parents('form')[0])

    for (var pair of formData.entries()) {
        if (pair[1] instanceof Blob) {
            formSize += pair[1].size
        } else {
            formSize += pair[1].length
        }
    }

    if (formSize > this.max_post_size) {
        isError = true
    }

    attachmentBlock.append(this.labelTemplate({'fileName': fileName}));

    **if (fileName.startsWith('Загрузка ПСЦ')) {
        alert(fileName)
        f = files[i]
        data = f.arrayBuffer()
        workbook = XLSX.read(data)
    }**
}
komal-sh-27 commented 1 year ago

@Evgl1

Can you please explain more about your query and what is the purpose of this binary data of the uploaded file?

Evgl1 commented 1 year ago

Hello. I need to process, parse, xls files... In this place, I want to get binary data files[i] Depending on the result of processing, I will allow this file to be uploaded or forbid ...

Evgl1 commented 1 year ago

files[i].arrayBuffer().then(buffer => { xlsx = XLSX.read(new Uint8Array(buffer), {type: 'array'}) console.log(xlsx)