当前位置:网站首页>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
边栏推荐
- 【C 题集】of Ⅴ
- Market Research - current market situation and future development trend of night vision goggles for pilots
- Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning
- 服务可见可观测性
- Pointer - function pointer
- 服务器响应状态码
- 杰理之如何测试按键的误触率【篇】
- Market Research - current market situation and future development trend of aircraft wireless intercom system
- UE4 UI自适应屏幕
- Market Research - current situation and future development trend of preclinical medical device testing service market
猜你喜欢
![NC24325 [USACO 2012 Mar S]Flowerpot](/img/cf/86acbcb524b3af0999ce887c877781.png)
NC24325 [USACO 2012 Mar S]Flowerpot

New feature of go1.18: trylock, which has been tossed n times

图形视图框架

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

Oracle-游标
![[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)](/img/2b/f31b81cedf37ca187bcaa20dfe0b83.png)
[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)

Socket socket c/s end process
![[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)

Dynamic memory allocation (malloc calloc realloc free)

Struct, bit segment, enumeration, union
随机推荐
Methods of adding styles to native JS
《乔布斯传》英文原著重点词汇笔记(九)【 chapter seven】
SimpleITK使用——4. 奇怪的问题
[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)
Using rendertext() to output multiple lines of text with rendertext() in R shiny
U++ 原始内存 学习笔记
Market Research - current situation and future development trend of anterior cruciate ligament (ACL) reconstruction Market
Leetcode circular linked list (fast and slow pointer) code line by line interpretation
Task and privilege level protection
wait解决僵尸进程
[autosar-dcm] - 4.3-how UDS $22 and $2e services read and write NVM data
Perceptron model and Application
Unity3d learning notes 4 - create mesh advanced interface
UE4 游戏架构 学习笔记
Reading experience of just because
影视随摘
[QT] Q multithreaded development - Analysis of multithreaded application examples (Mandelbrot)
[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)
Bridge emqx cloud data to AWS IOT through the public network
【外刊】睡眠与减肥