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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.