I am downloading files in express js and react Js with ajax request. pdf , php , zip , etc every file is downloading but when i want to download docx file it is not working.
my code dowload every type of file but not docx file.
Front End Code
getfile(cell) {
console.log(cell)
var filename = cell ;
$.ajax({
type: 'GET',
url: '/filedownload/' + filename,
success: function () {
window.open('/filedownload/' + filename, '_blank');
}
});
}
server side code
app.get('/filedownload/:filename', function (req, res) {
var file = req.params.filename
res.download(__dirname + '/uploads/' + file);
});