Get selected path from response
I am using
response.headers['Content-Type'] = gluon.contenttype.contenttype('.xls')
response.headers['Content-disposition'] = 'attachment; filename=projects.xls'
to generate开发者_开发问答 save as dialog box.
Is there a way to get the selected path by the user?
The browser displays the Save As dialog box to the user, then writes your content into that file. It doesn't inform the server what path the content was saved to. I'm afraid you can't get that information.
If your question is about how to send the file contents to the user, you simply write the content to your response object. The browser takes care of actually writing the file to the path selected by the user.
In Django, you would do something like:
def view(request):
# get the file content from somewhere
response = HttpResponse(file_content, mimetype='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename=projects.xls'
return response
The browser will then prompt the user for a path and save the file "projects.xls" to that path.
精彩评论