You need two functions. The first will get the name of the old upload.
The second deletes it.
If using FORM or SQLFORM
def edit():
form = SQLFORM(db.sometable, somerecord, ...)
## the onvalidation function fires before SQLFORM commits the change but
after field validation.
if form.process(onvalidation=<function to get filename>).accepted()
## this function fires after SQLFORM has committed your changes
<functiontodeletefile(form)>
whatever ...
If using crud
def edit():
form = crud.update(db.sometable, somerecord, onvalidation=<function to
getfilename
>, onaccept=<functiontodeletefile> ...)
See "Forms and Validators" in the manual for details about onvalidation and
onaccept.
On Monday, November 12, 2012 2:29:03 PM UTC-5, David Marko wrote:
>
> How do you deal with obsolete uploaded files? I have a table definition
> with upload file field. When user uploads the file to document and later
> reedit the document and upload the different file then the former file is
> left in uploads folder. Is there a way how to delete this obsolete file
> when new one is being uploaded?
>
> David
>
--