tdavis
08-11-2006, 03:53 PM
I found this script to upload photos to my server. It works great, but I am trying to change it to allow more than one. I did that by changing this to use a loop instead of 10 sections of the code (I want to allow up to 10). It loops fine, and puts up the 10 files, but they are ZERO BYTES. I guess it is not really reading the image file.
Is the problem my substitution of a variable name (see code below)???
Thanks!
use CGI;
$query = new CGI;
@filename[0] = $query->param("photo01");
@filename[1] = $query->param("photo02");
@filename[2] = $query->param("photo03");
@filename[3] = $query->param("photo04");
@filename[4] = $query->param("photo05");
@filename[5] = $query->param("photo06");
@filename[6] = $query->param("photo07");
@filename[7] = $query->param("photo08");
@filename[8] = $query->param("photo09");
@filename[9] = $query->param("photo10");
##Upload the photos##
for ($i = 0; $i < 9; $i++) {
$filename = @filename[$i];
if ($filename ne "") {
$filename =~ s/.*[\/\\](.*)/$1/;
###$upload_filehandle = $query->upload("photo1");
$upload_filehandle = $query->upload($filename); Replaced
open UPLOADFILE, ">$upload_dir/$filename";
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
}
}
Is the problem my substitution of a variable name (see code below)???
Thanks!
use CGI;
$query = new CGI;
@filename[0] = $query->param("photo01");
@filename[1] = $query->param("photo02");
@filename[2] = $query->param("photo03");
@filename[3] = $query->param("photo04");
@filename[4] = $query->param("photo05");
@filename[5] = $query->param("photo06");
@filename[6] = $query->param("photo07");
@filename[7] = $query->param("photo08");
@filename[8] = $query->param("photo09");
@filename[9] = $query->param("photo10");
##Upload the photos##
for ($i = 0; $i < 9; $i++) {
$filename = @filename[$i];
if ($filename ne "") {
$filename =~ s/.*[\/\\](.*)/$1/;
###$upload_filehandle = $query->upload("photo1");
$upload_filehandle = $query->upload($filename); Replaced
open UPLOADFILE, ">$upload_dir/$filename";
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
}
}