I could if I had that Data:: module or the power to have it installed. Alas, I do not. I do thank you for your continued suggestions. I checked the value of $filename and it is the name of the file I'm attempting to upload.
I had an older version of my script that worked, but it didn't pass variables and I had to create a new subroutine for each file upload field (I have two):
## OLD CODE
sub Store_Results{
my $data;
my $mime = uploadInfo($File_Name)->{'Content-Type'};
open (STORAGE, ">$Directory/$File_Name") or die "Error: $Directory
+/$File: $!\n";
if($mime !~ /text/){
binmode ($File_Name);
binmode (STORAGE);
}
while( read($File_Name, $data, 1024) ){
print STORAGE $data;
}
close STORAGE;
}
## NEW CODE
#stores uploaded files
sub storeFiles{
my($filename, $directory) = @_; #name subroutine variables
my $data;
my $mime = uploadInfo($filename)->{'Content-Type'};
open (STORAGE, ">$directory/$filename") or die "Error: $directory/
+$filename: $!\n";
if($mime !~ /text/){
binmode ($filename);
binmode (STORAGE);
}
while( read($filename, $data, 1024) ){ print STORAGE $data;}
close STORAGE;
}
I was trying to make the code more reusable and so re-wrote the subroutine to pass the file name and the directory path, but it obviously doesn't work.
my $mime = uploadInfo($File_Name)->{'Content-Type'};
works, but
my $mime = uploadInfo($filename)->{'Content-Type'}; does not.
|