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.

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

Thanks Kevin,

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

The directories are set initially in the generated code, so look in there.

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.



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:

<input type=checkbox name="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.

If empty({yourfieldfile}) { DELETE THE FILE If exists }