in reply to Uploading pictures - displays only 2 of 12

libuska78:

I don't see anything obvious to cause the problem you're seeing. However, after looking over the code, I don't think your error is in that subroutine1. It's hard to check, though, as the code is hard to look at, due to all the repetition.

If you see the same thing happening over and over in your code, it's a sign that something's wrong. You don't want to do that, because it's hard to look over and be certain that you made the correct edit in each and every block. Instead, use a loop to do the work. That way, you can concentrate on getting the task correct with only a little loop overhead rather than copy and pasting the code over and over, and then making small hand edits to adjust filenames and such.

Here's a rework of your subroutine that outputs the same text as yours, but rather than using hardcoded variables $file1, $file2, ... $file12, $uploadfile1, ..., $uploadfile12, it uses two arrays: @files and @uploadfiles:

sub upload { if ($match){ print "<table align=center width=100% border=0 cellspacing=0 c +ellpadding=0>"; print "<tr><td align=center width=100%>"; print "<FORM ACTION=\"$config{'scripturl'}/cgi-bin/auction/auc +tion.cgi?action=uploaddone\&IMAGE1=$files[0]\" METHOD=POST>"; my $footer=''; for my $idx (0 .. $#files) { last if $idx > 11; ### Original code had 12 copies of the +same code... my $idx_n = $idx+1; print "<center><b><font face=arial size=2>Image file $idx_ +n:</b>: $files[$idx]</center>\n"; print "<center><font face=arial size=2>$uploadfiles[$idx] +<br><b>Upload Complete Image $idx_n.</b></font></center>\n"; print "<p><img src=$config{'imageuploadurl'}/$files[$idx]> +</p><hr width=80% size=1 color=$config{'bordercolor'}>\n"; $footer .= "<input type=hidden name=IMAGE$idx_n value=$fil +es[$idx]>"; if ($idx == 0) { ### Original code only created THUMB for first file... $footer .= "<input type=hidden name=THUMB$idx_n value= +$files[$idx]>"; } } print $footer; print "</td></tr></table>"; print "<center><p><font face=arial size=2>If the image(s) are +correct. Click \"Continue\".</font></center></p>"; print "<center><p><font face=arial size=2><font face=arial siz +e=2>If they are not correct, use your browsers back button to try aga +in.</font></center></p>"; print "<center><input type=submit value=\"Continue\"></center> +"; print "</form>"; } }

There are other cleanups you can make, but I stopped at rolling your code up into a loop.

...roboticus

Update: Added this footnote:

1: Unless the problem is related to the THUMB input field being missing from items 2 through 12.