Reputation: 462
I want to download a file returned by a php page when invoked by a jquery event. I red that inserting an <iframe>
could do the trick, but It says on w3school that this tag is deprecated. I wonder if there's any other solution.
I think it might be relevent to say that the event that trigger the download is a button from a modal window using simple-modal. I want keep that window opened after the event.
It's the first time I'm downloading file with PHP so there might be an easy way to achieve this that i'm unaware of.
Upvotes: 0
Views: 681
Reputation: 5755
You can make an alternate php file that will force download when you click the button. Use headers in php this might help : headers
Upvotes: 1
Reputation: 553
You may use PHP to redirect to the file under certain permissions.
<?php
if($username == "soandso") {
header("Location: download.exe");
}
?>
Also, the <iframe>
tag is not deprecated. Still works for old and new browsers.
Upvotes: 0