fix #2172 - File Upload issue caused by JS Interop not passing AntiForgery token in POST methid
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Antiforgery;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@ -38,6 +39,7 @@ namespace Oqtane.Security
|
||||
catch
|
||||
{
|
||||
context.Result = new AntiforgeryValidationFailedResult();
|
||||
Debug.WriteLine($"Oqtane Error: AutoValidateAntiforgeryTokenFilter Failure on {context.HttpContext.Request.Path}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ Oqtane.Interop = {
|
||||
}
|
||||
return files;
|
||||
},
|
||||
uploadFiles: function (posturl, folder, id) {
|
||||
uploadFiles: function (posturl, folder, id, antiforgerytoken) {
|
||||
var fileinput = document.getElementById(id + 'FileInput');
|
||||
var files = fileinput.files;
|
||||
var progressinfo = document.getElementById(id + 'ProgressInfo');
|
||||
@ -326,6 +326,7 @@ Oqtane.Interop = {
|
||||
var FileName = file.name + ".part_" + PartCount.toString().padStart(3, '0') + "_" + TotalParts.toString().padStart(3, '0');
|
||||
|
||||
var data = new FormData();
|
||||
data.append('__RequestVerificationToken', antiforgerytoken);
|
||||
data.append('folder', folder);
|
||||
data.append('formfile', Chunk, FileName);
|
||||
var request = new XMLHttpRequest();
|
||||
|
Reference in New Issue
Block a user