using a PHP script with fread method, to download a private file (CHMOD=600), I realize that cant redirect the user, using header(..) function, after download.. whats next? javascript!!
for each table row, I set
plus at javascript a jQ dynamic anchor click event handler, without use the famous
to prevent the href redirection.
when click the anchor, the result is :
-a new tab popup and call the download function (external PHP file)
-at the same time reload the page (has the grid, contains the anchor) to update the record status
JavaScript:
//dynamic handler for grid buttons
$(document).on("click", "#invoice_download", function(e) {
location.reload(true);
});
var jArray_contracts = <?php echo json_encode($contracts); ?>;
var combo_contracts_rows = "";
for (var i = 0; i < jArray_contracts.length; i++)
{
combo_contracts_rows += "[TD]<a id='invoice_download' target='_blank' href='download.php?id=" + jArray_contracts[i]["offer_id"] + "' class='btn btn-danger btn-xs']Download</a>[/TD][/TR]";
}
$("#contracts_rows").html(combo_contracts_rows);
[TABLE]
<tbody id="contracts_rows">
[/TABLE]
for each table row, I set
JavaScript:
<a id='invoice_download' target='_blank' href='download.php?id=']Download</a>
plus at javascript a jQ dynamic anchor click event handler, without use the famous
JavaScript:
e.preventDefault();
when click the anchor, the result is :
-a new tab popup and call the download function (external PHP file)
-at the same time reload the page (has the grid, contains the anchor) to update the record status
