I have a button that, when clicked in Chrome or Firefox or Edge, shows the file browser window where I can then select a file and complete the file upload. However, when I click the button in Safari, nothing happens - the file browser window does not appear. I am running on Windows 10 and have a Windows version of Safari installed.
Button:
<a href="javascript:void(0)" id="uploadFile">Upload File</a>
Handler:
$(document).ready(function() {
$("#uploadFile").click(function() {
$("#uploadFileHandle").click();
$('html,body').css('cursor','progress');
var formdata = false;
if (window.FormData) {
formdata = new FormData();
}
$("#uploadFileHandle").on("change", function() {
$('html,body').css('cursor','progress');
var i = 0, len = this.files.length, file;
file = this.files[0];
formdata.append("fileUpload", file)
if (formdata) {
csrftoken();
$.ajax({
url: "/profile/uploadFile",
type: "POST",
data: formdata,
processData: false,
contentType: false,
success: function (response) {
if (response.success) {
var res = response.file;
$('html,body').css('cursor','default');
}
}
})
}
});
});
});
Any ideas on how to get the file browser window to appear when the Upload File button is clicked in Safari?