I am trying to upload a file from a web form. I've read How can I get started with a file upload script? and, in the spirit of that answer, here is what I have:
The form is generated by a template (of which this is a snippet) as such:
<form method="get" action="./source_definition" enctype="multipart/for
+m-data">
<p><input type="file" name="upload_file"></p>
</form>
Then the snippet of code that handles the upload looks like this:
my $filename = $cgi->param('upload_file');
binmode($filename);
my $test = "";
my $buffer;
while ( read($filename, $buffer, 1024) ) {
$test .= $buffer;
}
The goal is to have the whole file in $test. The problem is that at the end of it
$test is empty. What have I missed?
Thanks