I am trying to get documents(ie. pdf, excel, word doc, etc) to open in a download box. for some reason the excel files work correctly but none of the others do. I think I need to setHeader using javascript(i believe that jquery does not have core functions that do this, but correct me if i’m wrong). here is a sample of my code.
$(function() {
$('a.media-link').click(function(event){
var fileName = $(this).html();
var property_id = $("input[name=capturePropId]").val();
//alert(fileName);
event.preventDefault(); //stop the browser from following
window.location.href = '../uploads/properties/'+
property_id+'/media/'+fileName+'';
response.setHeader("Content-Disposition", "attachment;
filename=\"" + fileName + "\"");
});
});
When i do this i get an error “response.setHeader response is undefinded. does anyone have any ideas?
You need to set the headers differently for each filetype. Take a look here.