I'm generating a file dynamically in php like this :
$attachment_url = "http://www.mysite.com/file.jpg";
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="'.basename( $attachment_url ).'"');
header('Content-Transfer-Encoding: binary');
header('Connection: close');
readfile( $attachment_url );
This data in then passed through jQuery.ajax
I'd like to make it open a file download dialog upon success.
Right now I have this :
success: function(data, textStatus, XMLHttpRequest) {
var win = window.open();
win.document.write(data);
}
This does open a new window and display the raw file data. Instead I would like a download dialog to open.