Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying multiple images from array

Status
Not open for further replies.

shakezy

Programmer
Oct 10, 2010
2
US
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 some pics are repeated 2 or 3 times.

Here's the html and the perl code:
Code:
html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>

<form action="[URL unfurl="true"]http://localhost/code.pl"[/URL] 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>

i gave all file uploads the same name bcos its easier for me to put and arrange in an array

Perl:
Code:
#!/usr/bin/perl 
    
   use warnings;
   use CGI;
   use CGI::Carp qw/fatalsToBrowser/;

   my $query = new CGI;
   
   $upload_dir = 'C:/mystuff_htm/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";		 

}
 
oh yeah, all pics uploaded are in the array, so thats not the problem. The files are there, i guess the problem arises in the print<img src ..> part
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top