In web2py I have an init application and an adminmod application containing
the model, module and static files.
To manage images I have the following code in a function:
table.image.uploadfolder = os.path.join(request.env.applications_parent,
'applications',
'adminmod', 'static/uploads',
folder)
form = SQLFORM(table, record, deletable=True, showid=False,
upload=URL('adminmod', 'static/uploads', folder,
args=request.vars.image))
if hasattr(request.vars.image, 'filename'):
form.vars.imageFilename = request.vars.image.filename
if form.process().accepted:
if record and form.vars.image__delete:
file = record.image
os.remove(os.path.join(request.env.applications_parent,
'applications',
'adminmod', 'static/uploads', folder,
file))
In production I have a symbolic link application referenced by a subdomain:
images.mydomain.com
In the init application images have the following source selector:
<img src="/adminmod/static/uploads/node{{='%s'
%str(request.args(0))}}/{{=row.image}}" class="img-responsive center-block"
alt="" />
Is it possible to upload the image to an uploadfolder outside web2py, so
instead to this folder:
/home/username/webapps/w2p/web2py/applications/adminmod/static/uploads
to this folder:
/home/username/webapps/uploads
Kind regards,
Annet
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (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
to [email protected].
For more options, visit https://groups.google.com/d/optout.