Do not delete the current Input[type=file] This node, and then re-create the DOM this scenario, this is unreasonable.
The explanations are as follows:
Input[type=file] Use onchange to do, onchange listen to the value of input, only when the content changes to trigger the time, and value in the upload file is the content of the file, you only need to upload the successful callback inside To empty the value of the current input.
Event.target.value= ";
Getinputfile (event) {
if (event.target.files.length) {
Let FormData = new FormData ()
Formdata.append ("File", Event.target.files[0])
this. $http ({
Method: ' Post ',
Async:true,
Crossdomain:true,
Url:${this.api.uploadData.uploadUrl}
,
Headers: {
"Cache-control": "No-cache",
"Postman-token": "19899c72-855a-49a1-494b-fe42b45d5d5e"
},
Processdata:false,
Contenttype:false,
Cors: {
All requests is expected to be cross-domain requests
Expected:true,
If you want cookie to being sent along with the request
Sendcredentials:true
},
MimeType: "Multipart/form-data",
Data:formdata
}). Then (res = {
if (!res.data.data.errtotal) {
This.curmask = True
This.uploadsuccess = True
This.uploadfail = False
}else{
This.curmask = True
This.uploadfail = True
This.uploadsuccess = False
This.errnumber = Res.data.data.errTotal
This.errurl = Res.data.data.errUrl
}
Event.target.value= "
}). catch (E = = {
Event.target.value= "
this. $alert (e.response.data.msg)
})
}
}
input type file onchange in the process of uploading files, encountered the same file two times the issue of invalid upload.