I forgot to say, uploading an image works, if the folder isn't
there it is being created, otherwise the image is uploaded
to the folder.
Best,
Annet
Op maandag 2 november 2020 om 16:17:48 UTC+1 schreef Annet:
>
> To upload images to separate folders outside web2py I set the upload
> folder with the model definition:
>
> UPLOADSDIR = '/home/me/apps/static/'
>
> db.define_table('mytable',
> Field('image', 'upload', autodelete=True, uploadfolder=os.path.join(
> UPLOADSDIR, 'vertexID%s' % session.vertexID),
> ...)
>
>
> I use the standard download function:
>
> def download():
> return response.download(request, db)
>
>
> The form:
>
> form = SQLFORM(table, row, deletable=True, upload=URL('default',
> 'download'), showid=False, buttons=buttons)
> if hasattr(request.vars.image, 'filename'):
> form.vars.imagefilename = request.vars.image.filename
>
>
> and to process the form:
>
> if form.process().accepted:
> if row and form.vars.image__delete:
> file = row.image
> os.remove(os.path.join(UPLOADSDIR, 'vertex%s' %
> session.back_end_vertexid, file))
>
>
> In web2py 2.17.2 this all worked without problem, however, after upgrading
> to
> web2py 2.20 it no longer works. The image doesn't show in the form, it's
> marked
> with a broken link icon, and when I click the file link I get a page not
> found error.
> Also when I upload a new image, the old one isn't being deleted, so the
> images pile
> up in the folder.
>
> I hope someone knows how to solve this issue.
>
>
> 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/cfcae028-a4fb-46ca-91b5-49abbc30a21en%40googlegroups.com.