Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 能否禁用大文件base64编码的页面无响应弹出窗口_Javascript_Reactjs_Base64 - Fatal编程技术网

Javascript 能否禁用大文件base64编码的页面无响应弹出窗口

Javascript 能否禁用大文件base64编码的页面无响应弹出窗口,javascript,reactjs,base64,Javascript,Reactjs,Base64,我试图阻止弹出窗口,即当一个大文件正在进行base64编码时,页面没有响应。我有下面的代码在技术上有效 const handleUpload = (uploadEvent) => { setLoaderActive(true) handleFile(uploadEvent.target.files[0]) .then((value) => { setInhoud(value); setLoaderActi

我试图阻止弹出窗口,即当一个大文件正在进行base64编码时,页面没有响应。我有下面的代码在技术上有效

const handleUpload = (uploadEvent) => {
    setLoaderActive(true)
    handleFile(uploadEvent.target.files[0])
        .then((value) => {
            setInhoud(value);
            setLoaderActive(false)
        })
        .catch((error) => {
            console.log(error)
            setLoaderActive(false)
        })
}

const handleFile = (file) => {
    return new Promise((resolve, reject) => {
        const reader = new FileReader()
        reader.onloadend = function (event) {
            const text = (event.target.result)
            setInhoudDisplay(text);
            setFileName(event.name)
            //let result = Buffer.from(text).toString('base64')
            let result = btoa(unescape(encodeURIComponent(text)))
            resolve(result);
        };

        reader.onerror = function (event) {
            reject(event);
        };

        reader.readAsText(file)
    })
}
对于小文件,没有太大问题,加载程序出现,内容被编码,一切正常,加载程序消失。例如,对于9Mb更大的文件,需要花费更长的时间,浏览器开始抱怨页面没有响应。但是,如果您只是等待,编码最终会完成,一切都会好起来

有没有办法防止浏览器抱怨页面没有响应?出于这个理由,我们使用Chrome作为浏览器