How to display multiple images in an array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ronnie gordon
    New Member
    • Oct 2010
    • 1

    #1

    How to display multiple images in an array

    Hi... I have 4 pics ( jpeg) in an array, but i'm having trouble displaying them all. It never displays all pics, tends to display them in random order, and sometimes pics are repeated 2 or 3 times.

    Here's the html and the perl code:
    html:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
    <html>
    
    <form action="http://localhost/code.pl" method="post" target="_blank" enctype="multipart/form-data" >
    
    
    <input type="file"  name="photo" size="15">
    <input type="file"  name="photo" size="15">
    <input type="file"  name="photo" size="15">
    <input type="file"  name="photo" size="15">
    
    <input type="submit" value="Submit"><input type="reset" value="Start Over" />
    
    </form>
    </html>
    perl:

    Code:
    #!/usr/bin/perl
        
       use warnings;
       use CGI;
       use CGI::Carp qw/fatalsToBrowser/;
    
       my $query = new CGI;
       
       $upload_dir = 'C:/hut/uploads';
       
       
       my @fh = $query->upload('photo');
    
       my $filename = $query->param("photo");
    
    
       print "Content-type: text/html\n\n";
    foreach my $fhan(@fh){
       open (UPLOADFILE, ">$upload_dir/$filename") or error($!);
       binmode UPLOADFILE;
       while ( <@fh> ) {
          print UPLOADFILE;
       }
    
    }
       close UPLOADFILE;
    
    
    foreach $fhan(@fh){
    print "<img src=\"uploads/$fhan\" alt=\"Pic\">\n";        
    
    }
    thanks ...
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    Change:
    Code:
    while ( <[B]@fh[/B]> ) {
    To:
    Code:
    while ( <[B]$fhan[/B]> ) {

    Comment

    Working...