tags:

views:

31

answers:

2

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?

+2  A: 

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.

Ned Batchelder
how to pass the content to the file projects.xls
Neveen
+1  A: 

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.

ars