M
Melissa McGehee
Hi there! Been a while...3 years... but I'm back!
I have a script that uploads ONE user file. But I want to upload two. This
seems like a simple question...but in the newsgroup messages downloaded, I
cannot find anything that matches.
Please advise what I can do to upload multiple files. I have a section
commented out below that was SUPPOSED to allow the second file to
upload...but never worked. ALL SUGGESTIONS WELCOMED!
Many thanks! (and it's great to be back...)
~Melissa
---------------------------------
use CGI qw
standard);
$query = new CGI;
########################################################################
# Breaks down the name-value pairs.
########################################################################
foreach $key (sort {$a <=> $b} $query->param()) {
$CAT =$query->param('CAT');
$SKU =$query->param('SKU');
$MF =$query->param('MF');
$ITEM =$query->param('ITEM');
$L =$query->param('L');
$W =$query->param('W');
$H =$query->param('H');
$PRICE =$query->param('PRICE');
$DES =$query->param('DES');
$RSKU1 =$query->param('RSKU1');
$RSKU2 =$query->param('RSKU2');
$RSKU3 =$query->param('RSKU3');
$RSKU4 =$query->param('RSKU4');
$RSKU5 =$query->param('RSKU5');
$RSKU6 =$query->param('RSKU6');
$RSKU7 =$query->param('RSKU7');
$RSKU8 =$query->param('RSKU8');
$RSKU9 =$query->param('RSKU9');
$RSKU10 =$query->param('RSKU10');
$SUBITEM1 =$query->param('SUBITEM1');
$SUBDIMS1 =$query->param('SUBDIMS1');
$SUBPRICE1 =$query->param('SUBPRICE1');
$SUBITEM2 =$query->param('SUBITEM2');
$SUBDIMS2 =$query->param('SUBDIMS2');
$SUBPRICE2 =$query->param('SUBPRICE2');
$SUBITEM3 =$query->param('SUBITEM3');
$SUBDIMS3 =$query->param('SUBDIMS3');
$SUBPRICE3 =$query->param('SUBPRICE3');
next if ($key =~ /^\s*$/);
next if ($query->param($key) =~ /^\s*$/);
next if ($key !~ /^IMG$/);
# foreach $key {
# $Number = $1;
if ($query->param($key) =~ /([^\/\\]+)$/) {
$Filename = $1;
$Filename =~ s/^\.+//;
$File_Handle = $query->param($key);
}
open(LOG, ">../$CAT/$Filename") || &ErrorMessage;
undef $BytesRead;
undef $Buffer;
while ($Bytes = read($File_Handle,$Buffer,1024)) {
$BytesRead += $Bytes;
print LOG $Buffer;
}
push(@Files_Written, "../$CAT/$Filename");
$TOTAL_BYTES += $BytesRead;
$Confirmation{$File_Handle} = $BytesRead;
close($File_Handle);
close(LOG);
chmod (0777, "../$CAT/$Filename");
#########################################################
#
# next if ($key =~ /^\s*$/);
# next if ($query->param($key) =~ /^\s*$/);
# next if ($key !~ /^THUMB$/);
# $Number = $1;
#
# if ($query->param($key) =~ /([^\/\\]+)$/) {
# $Filename2 = $1;
# $Filename2 =~ s/^\.+//;
# $File_Handle2 = $query->param($key);
#
# }
#
#
# open(LOG, ">../../PDC/$CAT/$Filename2") || &ErrorMessage2;
#
# undef $BytesRead;
# undef $Buffer;
#
# while ($Bytes = read($File_Handle2,$Buffer,1024)) {
# $BytesRead += $Bytes;
# print LOG $Buffer;
# }
#
# push(@Files_Written2, "../../PDC/$CAT/$Filename2");
# $TOTAL_BYTES += $BytesRead;
# $Confirmation{$File_Handle2} = $BytesRead;
#
# close($File_Handle2);
# close(LOG);
#
# chmod (0777, "../../PDC/$CAT/$Filename2");
#
#
#########################################################
$file = $SKU . ".txt";
$IMG2 = $Filename;
# $TIMG2 = $Filename2;
open(LOG, ">../$CAT/$file") || &ErrorMessage;
chmod(0777, "../$CAT/$file");
print LOG "$CAT\n";
print LOG "$SKU\n";
print LOG "$MF\n";
print LOG "$ITEM\n";
print LOG "$L\n";
print LOG "$W\n";
print LOG "$H\n";
print LOG "$PRICE\n";
print LOG "$IMG2\n";
# print LOG "$TIMG2\n";
print LOG "$DES\n";
print LOG "$RSKU1\n";
print LOG "$RSKU2\n";
print LOG "$RSKU3\n";
print LOG "$RSKU4\n";
print LOG "$RSKU5\n";
print LOG "$RSKU6\n";
print LOG "$RSKU7\n";
print LOG "$RSKU8\n";
print LOG "$RSKU9\n";
print LOG "$RSKU10\n";
print LOG "$SUBITEM1\n";
print LOG "$SUBDIMS1\n";
print LOG "$SUBPRICE1\n";
print LOG "$SUBITEM2\n";
print LOG "$SUBDIMS2\n";
print LOG "$SUBPRICE2\n";
print LOG "$SUBITEM3\n";
print LOG "$SUBDIMS3\n";
print LOG "$SUBPRICE3\n";
close(LOG);
print <<HTML_CODE;
I have a script that uploads ONE user file. But I want to upload two. This
seems like a simple question...but in the newsgroup messages downloaded, I
cannot find anything that matches.
Please advise what I can do to upload multiple files. I have a section
commented out below that was SUPPOSED to allow the second file to
upload...but never worked. ALL SUGGESTIONS WELCOMED!
Many thanks! (and it's great to be back...)
~Melissa
---------------------------------
use CGI qw
$query = new CGI;
########################################################################
# Breaks down the name-value pairs.
########################################################################
foreach $key (sort {$a <=> $b} $query->param()) {
$CAT =$query->param('CAT');
$SKU =$query->param('SKU');
$MF =$query->param('MF');
$ITEM =$query->param('ITEM');
$L =$query->param('L');
$W =$query->param('W');
$H =$query->param('H');
$PRICE =$query->param('PRICE');
$DES =$query->param('DES');
$RSKU1 =$query->param('RSKU1');
$RSKU2 =$query->param('RSKU2');
$RSKU3 =$query->param('RSKU3');
$RSKU4 =$query->param('RSKU4');
$RSKU5 =$query->param('RSKU5');
$RSKU6 =$query->param('RSKU6');
$RSKU7 =$query->param('RSKU7');
$RSKU8 =$query->param('RSKU8');
$RSKU9 =$query->param('RSKU9');
$RSKU10 =$query->param('RSKU10');
$SUBITEM1 =$query->param('SUBITEM1');
$SUBDIMS1 =$query->param('SUBDIMS1');
$SUBPRICE1 =$query->param('SUBPRICE1');
$SUBITEM2 =$query->param('SUBITEM2');
$SUBDIMS2 =$query->param('SUBDIMS2');
$SUBPRICE2 =$query->param('SUBPRICE2');
$SUBITEM3 =$query->param('SUBITEM3');
$SUBDIMS3 =$query->param('SUBDIMS3');
$SUBPRICE3 =$query->param('SUBPRICE3');
next if ($key =~ /^\s*$/);
next if ($query->param($key) =~ /^\s*$/);
next if ($key !~ /^IMG$/);
# foreach $key {
# $Number = $1;
if ($query->param($key) =~ /([^\/\\]+)$/) {
$Filename = $1;
$Filename =~ s/^\.+//;
$File_Handle = $query->param($key);
}
open(LOG, ">../$CAT/$Filename") || &ErrorMessage;
undef $BytesRead;
undef $Buffer;
while ($Bytes = read($File_Handle,$Buffer,1024)) {
$BytesRead += $Bytes;
print LOG $Buffer;
}
push(@Files_Written, "../$CAT/$Filename");
$TOTAL_BYTES += $BytesRead;
$Confirmation{$File_Handle} = $BytesRead;
close($File_Handle);
close(LOG);
chmod (0777, "../$CAT/$Filename");
#########################################################
#
# next if ($key =~ /^\s*$/);
# next if ($query->param($key) =~ /^\s*$/);
# next if ($key !~ /^THUMB$/);
# $Number = $1;
#
# if ($query->param($key) =~ /([^\/\\]+)$/) {
# $Filename2 = $1;
# $Filename2 =~ s/^\.+//;
# $File_Handle2 = $query->param($key);
#
# }
#
#
# open(LOG, ">../../PDC/$CAT/$Filename2") || &ErrorMessage2;
#
# undef $BytesRead;
# undef $Buffer;
#
# while ($Bytes = read($File_Handle2,$Buffer,1024)) {
# $BytesRead += $Bytes;
# print LOG $Buffer;
# }
#
# push(@Files_Written2, "../../PDC/$CAT/$Filename2");
# $TOTAL_BYTES += $BytesRead;
# $Confirmation{$File_Handle2} = $BytesRead;
#
# close($File_Handle2);
# close(LOG);
#
# chmod (0777, "../../PDC/$CAT/$Filename2");
#
#
#########################################################
$file = $SKU . ".txt";
$IMG2 = $Filename;
# $TIMG2 = $Filename2;
open(LOG, ">../$CAT/$file") || &ErrorMessage;
chmod(0777, "../$CAT/$file");
print LOG "$CAT\n";
print LOG "$SKU\n";
print LOG "$MF\n";
print LOG "$ITEM\n";
print LOG "$L\n";
print LOG "$W\n";
print LOG "$H\n";
print LOG "$PRICE\n";
print LOG "$IMG2\n";
# print LOG "$TIMG2\n";
print LOG "$DES\n";
print LOG "$RSKU1\n";
print LOG "$RSKU2\n";
print LOG "$RSKU3\n";
print LOG "$RSKU4\n";
print LOG "$RSKU5\n";
print LOG "$RSKU6\n";
print LOG "$RSKU7\n";
print LOG "$RSKU8\n";
print LOG "$RSKU9\n";
print LOG "$RSKU10\n";
print LOG "$SUBITEM1\n";
print LOG "$SUBDIMS1\n";
print LOG "$SUBPRICE1\n";
print LOG "$SUBITEM2\n";
print LOG "$SUBDIMS2\n";
print LOG "$SUBPRICE2\n";
print LOG "$SUBITEM3\n";
print LOG "$SUBDIMS3\n";
print LOG "$SUBPRICE3\n";
close(LOG);
print <<HTML_CODE;