web2py does not like to delete files unless it is told to do so. You can do

Field('avatar','upload',autodelete=True)

This should work as you expect.

On Monday, 16 April 2012 08:30:25 UTC-5, weheh wrote:
>
> auth_user_table = db.define_table(
>     ... the usual suspects ...
>     Field('avatar', 'upload', ondelete='CASCADE', ...)
>     )
>
> Using the auth.profile() routine, if user uploads a profile picture, it 
> properly appears under the uploads directory. However, if user uploads a 
> new profile picture, the new picture duly gets uploaded but the old one 
> remains. It is now an orphan file. IMHO, the old profile pic should get 
> deleted when the new one takes its place. Otherwise, if you have a lot of 
> users and people change their profile pics frequently, you're going to end 
> up with a lot of orphaned files taking up disk space unnecessarily.
>
> I will submit this as a web2py ticket if it's considered a bug. As a 
> feature, I think it's only useful to Seagate and WD. ;-)
>

Reply via email to