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:
i gave all file uploads the same name bcos its easier for me to put and arrange in an array
Perl:
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";
}