php - force word docs, pdf, xls, etc to download by clicking on a link with jquery -


I try to open documents in a download box (eg .pdf, excel, word doctor, etc.) I am here. For some reasons Excel file works correctly but none of the others does this, I think I have to set the header that uses Javascript (I believe jquery does not have such a main function, But I'm wrong 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 the following window: Location.href = ' ../uploads/properties/ '+ Property_id +' / media / '+ filename +' 'response.setHeader ("content-dispute", "attachment; filename =" "+ filename +" \ "");} );});   

When I do this, I get an error "response.setHeader response is undefinded. Do not anyone have any ideas?

< Div class = "post-document" itemprop = "text">

You have to set the header separately for each file type. Take a look.

Comments