Gossamer Forum
Home : Products : DBMan : Customization :

can't delete record if no image exists...

Quote Reply
can't delete record if no image exists...
Hello.

I am using the dbman long/short HTML file with the multi-upload mod. works fine except that if you add a record, and don't add an image, the script gives an error "unable to open directory in delete records"

I need the program to delete the image when a record is deleted to save server space, but also need the script to delete a record if there is no image with it.

I suspect the problem exists here...in sub delete_records



if ($delete_list{$data[$db_key_pos]}) { # if this id is one we want to delete
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
if ($db_upload) {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
}
}
else { $output .= $line . "\n"; }
POC Web Services - www.POC.us
Quote Reply
Re: [lostboy] can't delete record if no image exists... In reply to
Here's a working section from one of my databases, just remove the line for deleting the counter file:

if ($delete_list{$data[$db_key_pos]}) { # if this id is one we want to delete
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
if ($db_upload) {
if (-e "$SAVE_DIRECTORY/$data[$db_key_pos]") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
unlink "$counter_dir/$data[$db_key_pos]"; #### remove counter file
}
}
}
else { $output .= $line . "\n";
}
########## end multiple file upload lines
}

foreach $key (keys %delete_list) {


Hope this helps ... it looks like you were missing a bracket in your copy.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] can't delete record if no image exists... In reply to
Hello and thanks. That definately worked. Sorry it took so long for a thank you...I hadn't realized there was a post.

Another quick question for same project...
I am using multi upload mod with friendly html, and just recently installed the "modify multiple records at once" mod which work great. Problem is I have autogenerate set to 'off' but when modifying multiple records I get the autogenerate form. Any way to get the mod to use my designed html form for this?

Thanks again!
~Rick
POC Web Services - www.POC.us
Quote Reply
Re: [lostboy] can't delete record if no image exists... In reply to
I've never used that mod, but it looks like it uses it's own form to modify records.

Perhaps you could modify the html coding within:

sub build_html_mult_record_form

to have it appear as you want it.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/