Skip to content

Commit

Permalink
Merge pull request #26514 from rutwikhdev/fix-download-redirect
Browse files Browse the repository at this point in the history
fix: download file instead of open in new window
  • Loading branch information
rutwikhdev committed May 22, 2024
2 parents 5cdad43 + c112380 commit 75412ba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frappe/core/doctype/file/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ frappe.ui.form.on("File", {
if (frm.doc.file_name) {
file_url = file_url.replace(/#/g, "%23");
}
window.open(file_url);

// create temporary link element to simulate a download click
var link = document.createElement("a");
link.href = file_url;
link.download = frm.doc.file_name;
link.style.display = "none";
link.click();
link.remove();
},

optimize: function (frm) {
Expand Down

0 comments on commit 75412ba

Please sign in to comment.