I installed the multiple file-upload module and everything seemed fine. However, when I try to delete a record that does not have an attached image related to it I get an error. I believe the module is trying to find an image file for the record even though there never was one. I can delete the records with pictures without any problem. Will the sub delete_records only work if there are associated picture files? Any help would be greatly appreciated. Thanks.
Jul 11, 2000, 1:53 PM
Veteran / Moderator (8669 posts)
Jul 11, 2000, 1:53 PM
Post #2 of 7
Views: 1408
I hadn't come across that.
Try making the change in red below:
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]";
}
}
JPD
http://www.jpdeni.com/dbman/
Try making the change in red below:
Code:
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]";
}
}
http://www.jpdeni.com/dbman/
Jul 11, 2000, 2:34 PM
Veteran / Moderator (8669 posts)
Jul 11, 2000, 2:34 PM
Post #5 of 7
Views: 1401
In other words, it didn't work.
Try putting quotes around the directory name.
if (-e "$SAVE_DIRECTORY/$data[$db_key_pos]") {
Wait a sec. I have another idea. If that doesn't work, try replacing the line with
if ($data[field number of your 'Graphic' field] eq 'Yes') {
Since the field is there, we might as well use it.
JPD
http://www.jpdeni.com/dbman/

Try putting quotes around the directory name.
if (-e "$SAVE_DIRECTORY/$data[$db_key_pos]") {
Wait a sec. I have another idea. If that doesn't work, try replacing the line with
if ($data[field number of your 'Graphic' field] eq 'Yes') {
Since the field is there, we might as well use it.

JPD
http://www.jpdeni.com/dbman/
Jul 11, 2000, 3:17 PM
Veteran / Moderator (8669 posts)
Jul 11, 2000, 3:17 PM
Post #7 of 7
Views: 1409
It's a new issue. No one had mentioned it before. I appreciate your telling me about it, so I can fix the mod.
I'm just glad I was able to figure it out -- finally!!!
JPD
http://www.jpdeni.com/dbman/

I'm just glad I was able to figure it out -- finally!!!
JPD
http://www.jpdeni.com/dbman/