Gossamer Forum
Home : Products : DBMan : Customization :

Multi-uploaded image,problem with modify.

Quote Reply
Multi-uploaded image,problem with modify.
Hi,I dont know if any one got this kind of problem as me.
I use Multiple upload mod,when ever users try to modify record,if they select BOTH, files to delete and also select files to upload IN THE MODIFY FORM,the record_html will not show images properly...
If this is the problem for multi-upload mod so,there are mean to make separate page of both delete form and upload form,or if users try to do both of them at a time there will be an error page said"no allowed".
or there is a better way to fix this problem.


Please Excuse me for my poor knoledge of PERL
Regards,
Act.
Quote Reply
Re: Multi-uploaded image,problem with modify. In reply to
Hi ,any1 has a solution to send user to "error page" if they he try to upload and delete files at the same time in html_record_form (for multiple upload mod)


Please Excuse me for my poor knoledge of PERL
Regards,
Act.
Quote Reply
Re: [act] Multi-uploaded image,problem with modify. In reply to
Just experianced a similar problem.

If I delete an image from a record and then try to modify and upload another image to the same record I receive the DBman internal error when trying to upload the new image. The only way of getting a new image in the record is deleting and adding the whole record again :/


DBMan encountered an internal error.

CGI ERROR==========================================

Error Message : unable to open directory. Reason: No such file or directoryScript

Location : /home/andre/cgi-bin/dbman/db.cgi

Perl Version : 5.006

Setup File : default.cfg

User ID : *****

Session ID : ******

Form Variables-------------------------------------------

Address : 6th Floor815 Pacific HighwayChatswoodNSW 2067

Company : BSA

Contact : Alan Alwood

Country : Australia

Email : Fax : 61 (0)2 9413 9922

Graphic : YesID : 1

Telephone : 61 (0)2 9413 9500

db : default

file-to-upload-1 : D:\Websites\11.9.02\images\distributors\map_australia.gif

modify_record : Modify Recorduid : *****

The directory is still there from when the image was uploaded the first time /images/distributors/1


Any thoughts?

Last edited by:

Formant: Sep 13, 2002, 3:04 AM
Quote Reply
Re: [Formant] Multi-uploaded image,problem with modify. In reply to
Quoted by JPDeni in response to deleting and adding new images:

I set it up very specifically so that users could delete images and upload other images within the modify page. They
do have to delete some before they upload others, so it may be that they would have to go to the modify screen
twice. But I don't know of any way around this.

-------
What you can do is to provide instructions within either the add_form or a database FAQ to explain to users how to manage the graphics within the database.

It is necessary to delete an image prior to uploading a new image if they are over the limit allowed for total bytes. To replace an image they should just be able to upload the new image file to replace what is already there.

But as stated they may have to modify the record more than once to get the final results. It should not be necessary to add a new record.

This thread in the FAQ under "Images" may help to answer your questions "Questions and Answers for Image Upload"

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Multi-uploaded image,problem with modify. In reply to
Problem I'm having is that when I delete an image I cannot upload a new one, it just errors. I have to delete the entire record and create a new record with the new image.

I've noticed that when I delete an image from a record it leaves the directory (i.e. images/1). The only way around it I have found without delete the entire record is to delete the "1" (or whatever ID directory) first then I can upload a new image without error.

So it seem the delete image option has to delete the directory its in as well.

How should I modify the script to do this? heres is current incarnation after the multiple file upload mod

sub delete_records {
# --------------------------------------------------------


my ($key, %delete_list, $rec_to_delete, @lines, $line, @data, $errstr, $succstr, $output, $restricted);
$rec_to_delete = 0;
foreach $key (keys %in) { # Build a hash of keys to delete.
if ($in{$key} eq "delete") {
$delete_list{$key} = 1;
$rec_to_delete = 1;
}
}
if (!$rec_to_delete) {
&html_delete_failure("no records specified.");
return;
}

open (DB, "<$db_file_name") or &cgierr("error in delete_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>;
close DB;

($restricted = 1) if ($auth_modify_own and !$per_admin);

LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { $output .= $line; next LINE; }
chomp ($line);
@data = &split_decode($line);
($output .= "$line\n" and next LINE) if ($restricted and ($db_userid ne $data[$auth_user_field]));

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"; }
}
foreach $key (keys %delete_list) {
$delete_list{$key} ? # Check to see if any items weren't deleted
($errstr .= "$key,") : # that should have been.
($succstr .= "$key,"); # For logging, we'll remember the one's we deleted.
}
chop($succstr); # Remove trailing delimeter
chop($errstr); # Remove trailing delimeter

open (DB, ">$db_file_name") or &cgierr("error in delete_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock

&auth_logging("deleted records: $succstr") if ($auth_logging);
$errstr ? # Do we have an error?
&html_delete_failure($errstr) : # If so, then let's report go to the failure page,
&html_delete_success($succstr); # else, everything went fine.
}

Last edited by:

Formant: Sep 13, 2002, 2:33 PM
Quote Reply
Re: [Formant] Multi-uploaded image,problem with modify. In reply to
Try using this verion .. I think you are missing or have misplaced a } in the code you have.

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]";
}
}
}
########## end multiple file upload lines
else { $output .= $line . "\n";
}
}
foreach $key (keys %delete_list) {

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Multi-uploaded image,problem with modify. In reply to
Still the same problem.

DBMan encountered an internal error. CGI ERROR==========================================Error Message : unable to open directory. Reason: No such file or directoryScript Location : /home/andre3709/cgi-bin/dbman/db.cgiPerl Version : 5.006Setup File : distributor.cfg
Quote Reply
Re: [Formant] Multi-uploaded image,problem with modify. In reply to
Are you trying to store your graphics within the cgi-bin directory? If so, this may cause problems. Move your graphics directory outside your cgi-bin directory and be sure it is chmodded correctly.

If that doesn't solve the problem recheck all your coding again making sure you made all the changes. If you don't have any luck after that, please make a text copy of your .cfg, html.pl and db.cgi files and provide a url to where they can be viewed.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Multi-uploaded image,problem with modify. In reply to
I think I've found the problem. Had a look on your faq page in the image section an noticed a post regarding FIX for file upload mod. The very last bit

Quote:


============= added note ====================

You may also need to change the following in sub validate_upload:

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

add quotes around directory:

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

Last edited by:

Formant: Sep 14, 2002, 3:47 PM