Gossamer Forum
Home : Products : DBMan : Customization :

problem with multiple file upload

Quote Reply
problem with multiple file upload
ok, i have multiple file upload working great using an array with specific filenames for full-size and thumbnail images. now i've added an "Add duplicate record" feature to copy some of the fields to the next record. I've created a form on the add_success page that adds a duplicate record by calling this sub in html:

Code:
sub html_add_duplicate {
#-------------------------------------------------------------
# form upload hack delicia
$form_upload_add =1; $page_title = "$html_title: Add duplicate";
&html_page_top;



print qq|
<FORM action="$db_script_url" method="GET">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
|;



$in{'dbkey'} =~ s/<.?B>//g;
my (%rec) = &get_record($in{'dbkey'});
html_record_form(&get_defaults2(%rec));



print qq|</TD></TR>
<TR><TD><CENTER>
<INPUT TYPE="SUBMIT" NAME="add_record" VALUE="Add Record">
<INPUT TYPE="RESET" VALUE="Reset Form"></CENTER></TD></TR>
<TR><TD> |;



&html_footer;
&html_page_bottom;
}


then, in db.cgi i have new subroutine get_defaults2:

Code:


sub get_defaults2 {

# --------------------------------------------------------

# Returns a hash of the defaults used for a new record.

my (%prev) = @_; #hack

my (%default);

foreach $field (keys %db_defaults) {

$default{$field} = $db_defaults{$field};

}

#######hack

@fields = split (/\,/, $db_copy_previous{$column});

foreach $field (%db_copy_previous) {

$default{$field} = $prev{$field};

}

#######

## hack delicia

unless ($per_admin) { ($auth_user_field >=0) and ($db_defaults{$db_cols[$auth_user_field]} = $db_userid); }

###



if ($db_key_track) {

open (ID, "<$db_id_file_name") or &cgierr("error in get_defaults. unable to open id file: $db_id_file_name.\nReason: $!");

if ($db_use_flock) { flock(ID, 1); }

$default{$db_key} = <ID> + 1; # Get next ID number

close ID;

}

return %default;

}


this seems to work fine for getting the default values. (i have an array in cfg similar to the radio button definitions to list the fields for copy_previous.)

my problem is that when i choose add duplicate it looks like everything is working but my files are not getting uploaded. dbman is creating my two files but they are both 0 bytes. help please !!!
Quote Reply
Re: [delicia] problem with multiple file upload In reply to
Figured it out! I compared code in add_record to my add_duplicate and noticed that the form action for add_record is POST instead of GET. changed that line to:

Code:
<FORM ENCTYPE="multipart/form-data" action="$db_script_url" method="POST">


and now it works great!
Quote Reply
Re: [delicia] problem with multiple file upload In reply to
This may not have helped you in your case but... I use a text editor called "TextPad" and it has a nifty feature called "compare files". I can cut & paste snippets of code and then compare them "side by side" almost and it really helps to find that missing comma, bracket, semi-colon, etc.

Glad you got it working!
Quote Reply
Re: [Watts] problem with multiple file upload In reply to
actually i had copied the add_duplicate routine straight from a file that was listed as a hack to add a duplicate record at the wonderful resource - unofficial faq (loisc). i don't know why it showed GET instead of POST but GET didn't work for me.

i use the compare documents feature in MS Word all the time to compare files. and before someone has a coronary, i never save a script in Word -- i just use it to compare but don't save anything. also, i use earthlink for webhosting and they have a great perl debugger that finds all my punctuation errors.

what would we do without these helpful tools!