in reply to Re: displaying image files in arrays
in thread displaying image files in arrays
i gave all file uploads the same name bcos its easier for me to put and arrange in an array initial perl 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 O +ver" /> </form> </html>
#!/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 ( <$fhan> ) { # i changed the $fhan and now working with @fh as filehandle print UPLOADFILE; } } close UPLOADFILE; foreach $fhan(@fh){ print "<img src=\"uploads/$fhan\" alt=\"Pic\">\n"; }
|
|---|