I'm trying to code a routine for uploading up to four images via a
CGI-form, using CGI.pm.
Filenames including local paths are stored in @files_to_upload.
At this point in the script I have the base names of each file in
@files_to_uploaded associated with the full filename in %basename, and the
extension in %imageextension. I separated these because I wanted to
validate the extensions and the filenames before the files are uploaded.
$imagepath is the server path to the image directory.
With the code given below, the appropriate files are created on the server,
but nothing is written to them.
foreach my $file (@files_to_upload) {
my $filename = "$basename{$file}" . "\.$imageextension{$basename{$file}}";
my $newfilename = "$image_path\/$filename";
print "TESTING - FILE: $file, FILENAME: $filename, NEWFILENAME:
$newfilename<br>";# prints ok
my $bytesread;
binmode (OUTFILE);
open(OUTFILE, ">$newfilename") || die ("Cannot write to $newfilename: $!");
while ($bytesread = read($file,$buffer,1024)) {
print qq|yep!|;# doesn't get printed
print OUTFILE $buffer;}
close ($file);
close (OUTFILE);
print qq|BYTES read: $bytesread<br>|;# no value for $bytesread
}
Suggestions?
Thanks,
Birgit Kellner
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]