ezekiel has asked for the wisdom of the Perl Monks concerning the following question:
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:
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?my $filename = $cgi->param('upload_file'); binmode($filename); my $test = ""; my $buffer; while ( read($filename, $buffer, 1024) ) { $test .= $buffer; }
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with uploading a file from a web form
by cLive ;-) (Prior) on Nov 12, 2002 at 02:18 UTC | |
|
Re: Problems with uploading a file from a web form
by dingus (Friar) on Nov 12, 2002 at 07:40 UTC | |
|
Re: Problems with uploading a file from a web form
by Sihal (Pilgrim) on Nov 12, 2002 at 13:41 UTC | |
by Sihal (Pilgrim) on Nov 12, 2002 at 13:46 UTC | |
|
Re: Problems with uploading a file from a web form
by iburrell (Chaplain) on Nov 12, 2002 at 16:59 UTC |