当前位置:网站首页>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
边栏推荐
- Market Research - current situation and future development trend of carob chocolate market
- Learn computer knowledge from scratch
- Unity3d learning notes 4 - create mesh advanced interface
- UE4 game architecture learning notes
- 20220702 how do programmers build knowledge systems?
- Market Research - current situation and future development trend of marine clutch Market
- Kubernetes resource object introduction and common commands (4)
- [micro service sentinel] rewrite Sentinel's interface blockexceptionhandler
- Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
- Oracle-游标
猜你喜欢

Simpleitk use - 3 Common operations
![[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)](/img/07/6f2dfb543cb0ab4f27169da7e6ad07.jpg)
[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)

Kubernetes resource object introduction and common commands (4)
![[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)

对象与对象变量

PMP项目整合管理

It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
![NC24325 [USACO 2012 Mar S]Flowerpot](/img/cf/86acbcb524b3af0999ce887c877781.png)
NC24325 [USACO 2012 Mar S]Flowerpot

phpcms实现订单直接支付宝支付功能

#include errors detected. Please update your includePath.
随机推荐
傑理之修改不需要長按開機功能【篇】
Market Research - current situation and future development trend of carob chocolate market
[shutter] shutter application theme (themedata | dynamic modification theme)
PHP optimizes SQL queries in foreach
New feature of go1.18: introduce new netip Network Library
数学建模——图与网络模型及方法(一)
Meibeer company is called "Manhattan Project", and its product name is related to the atomic bomb, which has caused dissatisfaction among Japanese netizens
Jerry's modification does not require long press the boot function [chapter]
#include errors detected. Please update your includePath.
[shutter] shutter gesture interaction (small ball following the movement of fingers)
Kubernetes resource object introduction and common commands (4)
大话云原生之负载均衡篇-小饭馆客流量变大了
Market Research - current situation and future development trend of preclinical medical device testing service market
Commodity information management system (C language document version)
杰理之内置短按再长按,不管长按多长时间都是短按【篇】
Perceptron model and Application
牛客网:龙与地下城游戏
#include errors detected. Please update your includePath.
[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)
[QT] QT multithreading development - reentrancy and thread safety