delete stored image

33 views
Skip to first unread message

nicor...@gmail.com

unread,
Jul 23, 2013, 4:18:24 PM7/23/13
to web...@googlegroups.com
i am making a product app in web2py everything is working really well exept one thing.

i upload the images like this:

        the_image = db.product_images.image.store(request.vars.image.file, request.vars.image.filename)
        img_id = db.product_images.insert(product_id=p_id , image=the_image , main_image=True)

that work awesome, it stores the image in the uploads folder.
now the problem is when i try to delete a image it only deletes the database record, and not the image itself stored in the uploads folder

this is how i delete my current image:

        db(db.product_images.id == img_id).delete()

i want to know how can i delete the image and not only the record so i dont store that amazing ammount of unused images in the server.

Txn for your help!!!

Niphlod

unread,
Jul 23, 2013, 5:06:13 PM7/23/13
to web...@googlegroups.com
use Field('image', 'upload', autodelete=True)

Nicolas Rodriguez

unread,
Jul 23, 2013, 5:12:26 PM7/23/13
to web...@googlegroups.com
Thanks :P awesome thats really simple hahaha :D


--
 
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/ULmgbt5L-1c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages