Gossamer Forum
Home : Products : DBMan : Customization :

multiple file upload * second request for help

Quote Reply
multiple file upload * second request for help
I'm having a problem with the multiple file upload mod.......it works fine to upload pictures and data in a record....but if i then try to "modify" a record by adding another picture file to the selected record. I get the following error message:



unable to open directory. Reason: No such file or directory



(this message is generated by sub validate_upload)

The cgi is able to make a directory and add pictures to it when I enter a record.....and it's able to find the files when I delete pictures....even when I delete them through "modify" so I'm thinking it's a code problem with the mod itself.......is there anyone running db manager with the mult. file upload mod who can then try to modify an existing record by adding another graphic? This would go a long way to deciding if it's my changes or if it's the code.



I have a lot of info going into the record so asking someone to delete the record and start over is not very user friendly and this problem is bound to come up.



thanks in advance, hopefully.



steven
Quote Reply
Re: [steven99] multiple file upload * second request for help In reply to
Hi Stephen,

I just tried to modify a record by adding an additional photo and I got the same error as you; "unable to open directory. Reason: No such file or directory

I am not a programmer but you are probably right that it is a mod error. Hopefully someone will be able to post a modification.

Regards,

Dave
Quote Reply
Re: [daverad] multiple file upload * second request for help In reply to
In a few sections of the mod there are placing where there are missing quotes around the defined directory.

For instance in:

sub validate_upload

if (!(-e "$SAVE_DIRECTORY/$newdirname")) { # add quotes

opendir (GRAPHIC, "$SAVE_DIRECTORY/$newdirname") or &cgierr("Unable to open directory. Reason: $!");

Changes or fixes to various mods are posted in the FAQ noted below.

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] multiple file upload * second request for help In reply to
Hi Lois, thank you for getting back to me....I made the changes you mentioned and fixed my problem....my first problem....

I now have a problem that has been addressed.....If someone creates an entry without adding at least one graphic then the record can not be deleted. In this case I want to require at least one graphic. If I change:

Graphic => [23, 'alpha', 0, 3, 0, '', 'Yes'],

the 0, to 1, (not null) it will come back and clame I haven't included a graphic even if I do.

I tried a work around....let people add without the graphic....then let them deleete the entry when they realize they have forgotten to ad the graphic....but db produces an error message if no graphic is added and the record is being deleted. I tried the fix at hypermart....


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.
-------------------------------------------------
Response:

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]'';
}
}


when I make these changes the cgi won't run....perl complains I've left out a right square or curly bracket on the final line of code....

sigh....

an ideas?

Thank you for your time.

steven99
Quote Reply
Re: [steven99] multiple file upload * second request for help In reply to
The portion of sub delete_records should look like 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) {
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]";
}
}
}
else { $output .= $line . "\n";
}

The example above should help to find which bracket you were missing.

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] multiple file upload * second request for help In reply to
Hi Lois....just wanted to say thank you for the help.....everything is now working....so now I'm going to add another mod.....

My bracket problem appears to have been here.....

rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
}
}
}


the fix for the mod posted at infomart(?) only had two trailing brackets I believe.

Anyhow....thank you Lois and the other folks who helped.



steven