Based on my experience and simple web protocols, you can't do what you 
want.  You could however combine all the images into one file (a zip file) 
and download that zip file.  In your controller you could do something like 

import os
import StringIO
import zipfile

tempfile = StringIO.StringIO()
ziph = zipfile.ZipFile(tempfile, 'w', zipfile.ZIP_DEFLATED)

#  psuedo code here
loop through all the picture files you want to download:
    ziph.write(file)  # add the file to the zip file - 'file' needs to be 
full path of the file

response.headers['Content-Disposition'] = 'attachment;'
response.headers['Content-Type'] = 'application/zip'
rtn = tempfile.getvalue()

return rtn

Hope this helps.

If you truly want to download multiple files at once I think you're going 
to have to go with some javascript magic.  Since it is a bit of 
non-standard way of doing things I've never attempted...


On Sunday, February 4, 2018 at 4:00:13 PM UTC-6, mostwanted wrote:
> I have a table which stores different images of different places, what i 
> want is for the site users to be able to download all the images of a 
> selected place
> by clicking the download button without having to download the images one 
> at a time. How can i achieve this??
> I tried this below:
> *MODEL:*db.define_table('location',
>                 Field('Image', 'upload'),
>                 Field('formTitle', requires=IS_NOT_EMPTY()), 
>                 Field('place', 'reference 
> area'),migrate=False,fake_migrate=True)
> *CONTROLLER*def areas():
>     images=db(
>     return dict(images=images, form=form)
> *VIEW*{{extend 'layout.html'}}
> <div>
> {{for pics in images:}}
>  <a style="margin-left: 60px;" 
> href="{{=URL('download',args=pics.Image)}}">Download</a>
>  {{pass}}
> </div>
> Unfortunately the above attempts do not give me what i want, please assist.
> Thank you.

- (Documentation)
- (Source code)
- (Report Issues)
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to