Gossamer Forum
Home : Products : DBMan : Customization :

help with muilty file upload mod.

Quote Reply
help with muilty file upload mod.
Hello I'm have a problem with deleting a record, I'm using "M U L T I P L E F I L E U P L O A D Written: 28 Jun 2000".

Mod based on a script created by Jeff Carnahan jeffc@terminalp.com Adapted for use by DBMan by JPDeni deni@jpdeni.com Integration with DBMan script by Jim Kangosjärvi Jim.Kangosjarvi@Abc.se

If I delete a record that has A photo with it. the mod works fine.
But if I delete a record that dose not have a photo with it I get a error.


I tried a few things to see if it would work, and this what I came up with.


In my "sub delete_records" if I put this --

$delete_list{$data[$db_key_pos]} ? #
($delete_list{$data[$db_key_pos]} = 0) : #
($output .= $line . "\n");

The record would delete, but the photo would stay on the server.


If I replace it with this --

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"; }


It will delete a record that has A photo with it.
But if I delete a record that dose not have a photo with it I get a error.

I also tried this fix I found on this site from LoisC

######### changed for file upload mod ###########
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

But I got a error on it.


I know I did something wrong, but I can't see it.

Thank you for your help.
Ed
Subject Author Views Date
Thread help with muilty file upload mod. knue 9105 Dec 10, 2006, 9:26 PM
Thread Re: [knue] help with muilty file upload mod.
JPDeni 9001 Dec 11, 2006, 7:24 AM
Thread Re: [JPDeni] help with muilty file upload mod.
knue 9031 Dec 11, 2006, 8:10 AM
Thread Re: [knue] help with muilty file upload mod.
JPDeni 8983 Dec 11, 2006, 9:40 AM
Thread Re: [JPDeni] help with muilty file upload mod.
knue 8990 Dec 11, 2006, 4:42 PM
Thread Re: [knue] help with muilty file upload mod.
JPDeni 8975 Dec 11, 2006, 5:16 PM
Thread Re: [JPDeni] help with muilty file upload mod.
knue 8986 Dec 11, 2006, 6:47 PM
Thread Re: [knue] help with muilty file upload mod.
knue 8986 Dec 11, 2006, 7:17 PM
Thread Re: [knue] help with muilty file upload mod.
JPDeni 9002 Dec 12, 2006, 7:04 AM
Thread Re: [JPDeni] help with muilty file upload mod.
knue 9008 Dec 12, 2006, 7:20 AM
Thread Re: [knue] help with muilty file upload mod.
JPDeni 8989 Dec 12, 2006, 7:40 AM
Thread Re: [JPDeni] help with muilty file upload mod.
knue 8995 Dec 12, 2006, 9:02 AM
Thread Re: [knue] help with muilty file upload mod.
JPDeni 8993 Dec 12, 2006, 9:04 AM
Thread Re: [JPDeni] help with muilty file upload mod.
knue 9011 Dec 12, 2006, 9:11 PM
Post Re: [knue] help with muilty file upload mod.
JPDeni 8997 Dec 13, 2006, 7:41 AM