On Friday, January 12, 2018 at 12:07:22 AM UTC-8, Annet wrote:
>
> 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
>
>
In addition to Stifan's remarks, I can attest that web2py can easily serve
files outside of the web2py tree, although in my case those files aren't an
upload field.
See also
<URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-constructor>
(there are several parameters related to uploads), and also
<URL:http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-and-uploads>
/dps
S
--
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.