What is the best way to dump a long string (13,000+ characters) into a downloaded file with a name and an extension? Using jQuery, possibly ajax or php, if needed.
Thank you.
function output(){
$.ajax({
dataType:"html",
type:"POST",
data:{
content:$("#fileDump").contents().find('html').html(),
fname:fileName
},
url:"filer.php",
success: function(data){
console.log(data);
},
error: function(data, status, error){
console.log(status);
console.log(error);
}
});
}
PHP :
Uses file_put_contents, header and readfile.
You can add a filename to the
Content-Dispositionif required :