On Monday, November 2, 2020 at 7:35:45 AM UTC-8, Annet wrote:
>
> 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
>
>
Is this related to slashes being dropped, as in Gael's question?
<URL:https://groups.google.com/d/msg/web2py/b5mApXO-9Io/FICcx2JlBgAJ>

/dps

 

> 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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f9d55e8e-a9ce-472d-b304-998392167af2o%40googlegroups.com.

Reply via email to