Announcement

Collapse
No announcement yet.

How can I make SC delete the image file of a field type Image (filename)?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I make SC delete the image file of a field type Image (filename)?

    When I delete a photo in my running SC app, by putting a check in the "Delete this record" check box, and clicking "Save". The image in the SC app goes away, but the actual file on disk remains. How can I tell SC that I want the associated file to be deleted from the HD as well?

    Thanks in advance.

  • #2
    Have the same problem in SC 6
    I had to add the programming to the on delete event
    Where the directory is the path to the file and the file
    name

    $dir = "../_lib/file/doc";
    $file = {news_file_name};

    unlink($dir.'/'.$file);

    Hope it helps

    Kevin

    Comment


    • #3
      Thanks Kevin,

      Does anyone know the SC internal var name for the images folder? I need to reference it.

      Comment


      • #4
        The directories are set initially in the generated code, so look in there.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          Hmmm...ok. I'm such a beginner. Hee hee hee. Ok, so I looked in the "View Source" on the page with the photo.

          I found what looks similar to Kdriscoll's post above, relating to folder (I use the "usr_profile_photo" subfolder)
          I put this in the .onBeforeUpdate of my record, since the photo name field is just one of many fields, I cannot put this code in the .onDelete event, because the user profile record will never be completely deleted.

          Code:
          if  WHAT_GOES_HERE?   == true 
          {
              $dir = "../_lib/img/usr_profile_photo";
              $file = {PHOTO_FNM};
              unlink($dir.'/'.$file);    
          };
          I found what looks like the little "Delete this record" checkbox:

          Code:
          <input type=checkboxname="photo_fnm_limpa" value="" onclick="this.value = ''; if (this.checked){ this.value = 'S'};">



          What is the proper syntax to use in my code snippet above, at the WHATGOESHERE? position , to check if the user has put a check in the "Delete this record" checkbox, so that I can delete the file on disk.

          Comment


          • #6
            If empty({yourfieldfile}) { DELETE THE FILE If exists }
            /Giuseppe

            Professional Scriptcase Services
            Some Customers opinions

            Comment

            Working...
            X