当前位置:网站首页>Solve the error of changing the selected file when uploading excel file. Net:: err_ UPLOAD_ FILE_ CHANGED
Solve the error of changing the selected file when uploading excel file. Net:: err_ UPLOAD_ FILE_ CHANGED
2022-07-02 22:46:00 【Mo Yuxuan】
Business scenario : In the business, first select the one to upload excel, And then back to excel Folder to open the file , Modify the file and save , Go back to the page and click upload ( This demand is also the first time I have encountered , Can only say a cow )
reason : After modifying the contents of the document file Your local file has been lost
solve :
1. Upload beforeUpload When will file Turn into base64(bese64 It has nothing to do with the local file status ), Again into file.( This is more troublesome , You can ask whether the backstage can change , adopt blob perhaps arraybuffer get data )
preservation base64 Format
const reader1 = new FileReader();
reader1.readAsDataURL(file);
reader1.onload = e => {
this.base64Excel = e.target.result;
};
base64 turn file Method :
base64ConvertFile (urlData, filename) { // 64 turn file
var arr = urlData.split(',');
var type = arr[0].match(/:(.*?);/)[1];
var fileExt = type.split('/')[1];
var bstr = atob(arr[1]);
var n = bstr.length;
var u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([ u8arr ], filename, {
type: type
});
},
Finally, turn it out file adopt formdata Upload
let excel = new FormData();
let form = this.base64ConvertFile(this.base64Excel, this.excelFile.name);
excel.append('file', form);
2. Click upload to prompt for file modification
this.file.slice( 0, 1 ) // only the first byte
.arrayBuffer() // try to read
.then( () => {
// The file hasn't changed , You can send a request here
console.log( 'should be fine' );
axios({.........})
} )
.catch( (err) => {
// There is something wrong with the document. , Stop here
console.log( 'failed to read' );
this.file = null; // Put the cached file Empty
} );programme 1 What is uploaded is the one before modification excel file , See whether the specific business can be accepted
programme 2 It is the optimal solution in the case that scheme 1 is unacceptable , Prompt to let go input Delete the file in and reselect it
Reference link :
solve excel There is an error in changing the selected file when uploading the file net::ERR_UPLOAD_FILE_CHANGED
边栏推荐
- Utilisation de simpletk - 4. Question étrange
- Necessary browser plug-ins for network security engineers
- [shutter] shutter gesture interaction (small ball following the movement of fingers)
- Market Research - current situation and future development trend of environmental friendly fireworks Market
- Market Research - current market situation and future development trend of high tibial osteotomy plate
- Oracle-游标
- 《乔布斯传》英文原著重点词汇笔记(十)【 chapter eight】
- Tencent three sides: in the process of writing files, the process crashes, and will the file data be lost?
- 佩服,竟然有人把高等数学这么晦涩难懂的科目,讲解得如此通俗易懂
- Market Research - current market situation and future development trend of total nutrition products
猜你喜欢

Source code analysis - lightweight asynchronous crawler framework Ruia
![[shutter] shutter application life cycle (foreground state resumed | background state paused | inactive | component separation state detached)](/img/4c/c8dae41fc2eb18b5153cf36861fc7d.jpg)
[shutter] shutter application life cycle (foreground state resumed | background state paused | inactive | component separation state detached)

Lightgbm principle and its application in astronomical data

SimpleITK使用——4. 奇怪的問題

NC50965 Largest Rectangle in a Histogram

New feature of go1.18: introduce new netip Network Library

Reading experience of just because

基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习
![[shutter] shutter opens a third-party application (url|launcher plug-in search and installation | url| launcher plug-in official example | open browser | open a third-party application)](/img/f7/cb41d159e5c5ef3f4f1b9468d52ccc.jpg)
[shutter] shutter opens a third-party application (url|launcher plug-in search and installation | url| launcher plug-in official example | open browser | open a third-party application)

腾讯三面:进程写文件过程中,进程崩溃了,文件数据会丢吗?
随机推荐
杰理之直接触摸样机的顶针反应不正常【篇】
Market Research - current market situation and future development trend of aircraft audio control panel system
Task and privilege level protection
How should programmers write logs
开发者分享 | HLS, 巧用AXI_master总线接口指令的定制并提升数据带宽-面积换速度...
Struct, bit segment, enumeration, union
Notes on key vocabulary in the English original of the biography of jobs (11) [chapter nine]
Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)
'when to use const char * and when to use const char []' - when to use const char * and when to use const char []
It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
Using emqx cloud to realize one machine one secret verification of IOT devices
Get off work on time! Episode 6 of Excel Collection - how to split and count document amounts
Kubernetes resource object introduction and common commands (4)
[QT] QT multithreading development - four methods to realize multithreading design
New feature of go1.18: trylock, which has been tossed n times
对象与对象变量
ServiceMesh主要解决的三大痛點
NC50965 Largest Rectangle in a Histogram
Il n'est pas nécessaire d'appuyer longtemps sur la fonction de démarrage pour modifier Jelly [chapitre]
Market Research - current market situation and future development trend of aircraft front wheel steering system