ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Delete file linked to entry

November 07, 2011 2:51pm

Subscribe [3]
  • #1 / Nov 07, 2011 2:51pm

    bertsinnema

    16 posts

    Hi all,

    I have a channel wich get filled by users in the frontend through SEAF with safecracker. I also let users link 1 file to the entry through safecracker file. 

    I searched and i searched but i dont know how to automaticly delete the linked file when the entry gets deleted or the file gets replaced.

    Can anyone help me out?

    Cheers

  • #2 / Nov 09, 2011 11:59am

    grantmx

    1439 posts

    You mean delete it from the server or from the entry?

  • #3 / Nov 09, 2011 4:50pm

    bertsinnema

    16 posts

    You’re right Marshall. I ment delete the dile from the server that is linked to the entry when it is removed.

  • #4 / Nov 09, 2011 5:15pm

    grantmx

    1439 posts

    Which version of ee are you running?  I know that nGen File Field gives you the option to delete the file completely from the server, but it runs on 1.7.x.


    If your running 2.x I don’t recall an option of completely removing the file from the server, just from the entry.

  • #5 / Nov 09, 2011 5:46pm

    bertsinnema

    16 posts

    I am running 2.3.1 right now.  I could always create a cron job that deletes unlinked files. But it would be so nice if EE did this for me.
    Any ideas?

  • #6 / Nov 09, 2011 8:45pm

    grantmx

    1439 posts

    Why do you want the user to delete the file on your server?  Even nGen had a security flaw as it created a chmod on the directory to delete the file, which is a no-no on a public facing site.

  • #7 / Nov 10, 2011 2:55am

    bertsinnema

    16 posts

    Because it is the users file and entry and I don’t want useless files floating arround taking up server space.

  • #8 / Nov 17, 2011 9:05am

    +1 for this

    Here’s the typical issue (and thus reason it’s something we want to do)...

    We allow content editors (often not web savvy) to create channel entries, and sometimes these channel entries will include a link to a file (which they can upload for themselves).

    When the channel entry is deleted, it would be nice to remove the uploaded file also (in order to prevent orphaned files).


    However, all this makes the assumption that the file:
    a) Isn’t going to be used again
    b) Isn’t used by another entry

    To take care of a) and b) might require more work - either asking the user if they’d like to delete any associated files (when the entry is deleted) and possibly keeping a ‘reference’ count against the file - so that it can only be deleted when it is no longer referenced by any channel entry.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases