10 Replies Latest reply on Dec 20, 2008 3:22 PM by Günter Schenk

    Delete an uploaded image

      Hi

      Can anyone give me instructions for deleting an uploaded image without deleting the whole record? For example, I have a record with an uploaded image, the image name stored in the table and the image in a directory. I change my mind and want no image associated with the record. How do I delete the image associated with the record and make that image name field null?

      Thanks
        • 1. Re: Delete an uploaded image
          The Wackonerd
          HI Steven,
          try this, about half way down the page
          http://www.interaktonline.com/Documentation/MXKollection/mx_kollection.htm#0925200_records .htm
          • 2. Re: Delete an uploaded image
            dizmarkie Level 1
            did this work for you?
            I checked this link but didn't see any relevant ways to delete associated files.

            still looking on how to achieve this.
            • 3. Re: Delete an uploaded image
              Level 1
              Hi Kevin

              I haven't look into it yet. It seems like being able to remove the image name from the table without deleting the record would be useful. Just a thought, in addition to the file field can you add a text field that gets the image name? But would go to the same row. So if you delete the image name in the text field and update, it deletes the images name from the record.
              • 4. Re: Delete an uploaded image
                dizmarkie Level 1
                Hi Steve,
                I'm afraid using a text field won't work in my case. I need to have this as user friendly for clients that do not need to enter paths or have any special instructions.

                I know there is a "delete file" server behaviour which I believe could be the answer. I just don't know how to integrate and where to put.

                I'm sure a custom trigger of some kind can be written but I rely completely on ADDT's wizards and do not know enough to write the logic myself.

                There must be a way to do this. Lets say someone uploads a file or an image to a record, then they decide the record doesn't need the file anymore. There must be a way to set the value back to NULL without delete and re-creating the whole record.

                I'll keep searching :)
                • 5. Re: Delete an uploaded image
                  Günter Schenk Level 4
                  Hi folks,

                  earlier this year I´ve written an ADDT tutorial named "Image & File Upload: overwrite existing file": http://www.guenter-schenk.com/tutorials/tutorial.php?id=7

                  I think that some parts of what´s described here (e.g. the Custom Trigger to delete a file "on demand") could also be modified for your slightly different purposes.

                  ------
                  There must be a way to set the value back to NULL without delete and re-creating the whole record
                  ------

                  Yeah, and in this context I´m sure my sample Custom Trigger would basically need an additional UPDATE query which sets the DB table´s "filename" column to ''

                  Cheers,
                  Günter Schenk
                  Adobe Community Expert, Dreamweaver

                  Cheers,
                  Günter Schenk
                  Adobe Community Expert, Dreamweaver
                  • 6. Re: Delete an uploaded image
                    dizmarkie Level 1
                    Thanks Gunter,
                    I think we are on the right track with this.

                    I am running into an issue since I am using a dynamic list to manager my add/update/delete records functionality.

                    When I try to add "Trigger_Delete_Existing" to the upload file behaviour or if I try to create a custom trigger I get "No more transactions availble"

                    I'll continue to grind it out and see what I can get going but I do love ADDT, I'm just suprised how much it can do but some of the obvious over sights for stuff like this can be frustrating.

                    I'll post my resolution or demise none the less, thanks as always Gunter.

                    Beers on me :)
                    • 7. Re: Delete an uploaded image
                      dizmarkie Level 1
                      OK, I have it working in a round about way. I'm sure with Gunters help I could get it going the 'proper way" but for now this solution seems to be working.

                      on my detail list I added a link "remove current file" which only shows on the conditional region "show if file exists" so if there is no file this link will not show.. so far so good.

                      I think pass the URL parameter to a page which I'm filter by URL ID parameted called "deletefile.php"

                      I then added an update record form and only included the field that is storing the filename. In the wizard I inserted the field as a hidden field. I added a second hidden field and called it "null" and left the value for it blank.

                      In the update record behaviour you can choose to get the values from any form element in the form area. So I chose to get the values from the hiidden object "null".

                      when you submit form it will then put the field for the file back to "null'

                      I'm sure i can get the form to delete the file as well. I'll work on that next.

                      This does seem a little dirty but seems to be working perfectly fine.

                      Hope this helps anyone.
                      • 8. Re: Delete an uploaded image
                        dizmarkie Level 1
                        I just added a "delete file" behaviour to that page I mentioned before and now it is deleting the file as well as putting the field in my DB back to null and keeping the record in tact!

                        exactly what I want.

                        If you couple this with conditional regions to show if file exists you can really make all these work arounds transparent and a nice admin flow for clients.

                        Just love when things figure themselves out, with help of course.

                        cheers everyone
                        • 9. Re: Delete an uploaded image
                          Level 1
                          Well done. That makes perfect sense. So you have link that only shows when the file field is not empty that goes to a delete file page. Sounds good to me.
                          • 10. Re: Delete an uploaded image
                            Günter Schenk Level 4
                            Hi Kevin,

                            very good find, kudos :-)

                            In my ADDT driven web applications at times I use to "outsource" certain extra features to popup windows (javascript driven plus a regular target=_blank) which - same as you did now - receive the primary key via URL parameter. Sometimes it´s way too complicated to try realizing each & every feature in one and the same form which - even if it works - gets too bloated and confusing

                            Cheers,
                            Günter Schenk
                            Adobe Community Expert, Dreamweaver