Gossamer Forum
Home : Products : DBMan : Customization :

file-upload.txt

Quote Reply
file-upload.txt
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.

Quote Reply
Re: file-upload.txt In reply to
I hadn't come across that.

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]";
}
}
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: file-upload.txt In reply to
Thank you for your time.

I did the above. Now I can delete records with or without files associated with them, but the graphics are not being automatically deleted. Is there a way to make this happen?


Quote Reply
Re: file-upload.txt In reply to
By the way, have I done something incorrectly. Does this module usually let you delete records with or without images associated to them? please advise. maybe I should reinstall the mod...?

Thanks again

Quote Reply
Re: file-upload.txt In reply to
In other words, it didn't work. Smile

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. Smile

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: file-upload.txt In reply to
Well, I tried the first solution and a solution it was indeed!

High five! ; )

My boss is gonna think I'm a genius....

Seriously though, is this a new issue with this module or did i muck something up along the away?

Either way, THANK YOU!



Quote Reply
Re: file-upload.txt In reply to
It's a new issue. No one had mentioned it before. I appreciate your telling me about it, so I can fix the mod. Smile

I'm just glad I was able to figure it out -- finally!!!


JPD
http://www.jpdeni.com/dbman/