I have a django response sending a file to a user, which is then simply ignored by the browser. How can I open the fileave dialog to save it?
Here is my Django code:
mimetype = "application/x-unknown"
file = somefilefromthedatabase
response = HttpResponse(file, mimetype=mimetype)
response["Content-Disposition"]= "attachment; filename=%s" % os.path.split(file.name)[1]
return response
When I access the view generating this directly, it saves the file in the database. When accessing it through jquery, nothing happens. jscode is here:
$(".jp-download").click(function(){
current=$("#download").data('current').find('.id').text();
$.post('/actions/',{action:'download',item:current});
});
marue source
share