I have created the form which holds three file browse with upload button.
<<CODE>>
<form enctype="multipart/form-data" method="post"
action="http://localhost/virtual/multi1.pl">
<input type=file name=file0 size="30"><br />
<input type=file name=file1 size="30"><br />
<input type=file name=file2 size="30"><br />
<input type="submit" value="Upload">
</form>
<<<<<<HERE I m trying to copy upload the files from one location to other
location within the system.
Server side code
use CGI::Carp qw( fatalsToBrowser );
use CGI ':standard';
$upload_dir = "d:/perl_up/";
$CGI::POST_MAX = 2048;
binmode(STDIN);
@inx = <STDIN>;
$ac = 0;
$ar = 0;
# This script has only been tested on IE6 and Firefox 1.0.7. If a
problem
# arises using another browser, it can probably be traced back to the
next two
# foreach loops, which break apart the form data sent from the browser.
# Remove key header elements from empty uploads.
foreach (@inx)
{
delete @inx[$ac] if $_ =~ /^Content-Type: application\/octet-stream/;
$ac++;
}
$ac = 0;
# Define individual uploaded files within the array
foreach (@inx)
{
if ($_ =~ /^Content-Type/) {
$filename[$ar] = $inx[$ac-1];
$array_reference[$ar] = $ac;
@working_filename = split /filename=/, $filename[$ar];
@working_filename = split /"/, $working_filename[1];
@working_filename = split /\\/, $working_filename[1];
$filename[$ar] = pop @working_filename;
$ar++;
}
$ac++;
}
$ac = 0;
$ar = 0;
print "content-type: text/html\n\n";
# Pull files from the array and write to disk
foreach (@filename)
{
$array_begin = $array_reference[$ac] + 2;
$array_begin = 0 if $array_begin < 0;
$array_end = $array_reference[$ac+1] - 3;
$array_end = ($#inx) if $array_end < 0;
for ($ii = $array_begin; $ii <= $array_end; $ii++) {$in .= $inx[$ii];}
$in = substr($in,0,length($in) - 2);
$save_file = "$upload_dir/$_";
open(FF,">$save_file") or die $!;
binmode(FF);
print FF $in;
close(FF);
$in = "";
$ac++;
print "Uploaded file $save_file<br />";
}
Report: Not working properly. Could you please check this.
--
View this message in context:
http://www.nabble.com/Multiple-files-upload-t1398596.html#a3761678
Sent from the Perl - ActivePerl forum at Nabble.com.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs