Hello all
I have a CGI script where a user indicates the location of an XML file on the file system through a form. On submission, the script should upload the file and store it in a database. At present, it seems to get all the correct information from the form but doesn't get the contents of the file. Here is what I have so far:
The relevant HTML form:
<p> Upload the file: <input type="file" name="upload_file"> </p>
The part of the code to get the file:
my $filename = $this->cgi()->param('upload_file'); my $xml = _upload_file($filename); sub _upload_file { my $filename = shift; my $file_contents = ""; my $buffer; while ( read($filename, $buffer, 1024) ) { $file_contents .= $buffer; } return $file_contents; }
At a guess it is because the $filename does not contain the full path to the file? However, I've seen the same code work in another program as is (I just cut'n'pasted it!). Furthermore, if I do need the full path, how do I get it from the HTML form?
Thanks.
In reply to Uploading files: can't find contents? by ezekiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |