Following is a post which I hope will clarify what I have been doing up until now, along with some questions regarding the correct way to do this.
Until now, I have always handled file uploads in the following way :
draw in HTML "<input type="file" name="filename">".
Then the form posts in on itself, and I use
my $newFile = $Request->Form('filename');
$newFile is then passed to a module which will basically do the following (along with a lot more):
while ($rets=read($newFile,$line,1024)) { # Read in BINARY
my @lin = $line;
my $status = append_file($destination_path, $file,\@lin);
if (!$status) {
return(0,"error storing file on server ($!)");
}
@lin = ();
}
This has always worked for me.
Now however, I need to not only upload the file to the server, but I need to store the filename in a database (among doing other things with the filename).
When you say filename, I will assume you mean the file name client side being uploaded...So should I be doing : my $newFile = $Request->{FileUpload}{filename}; $newFile = $newFile->{BrowserFile};Right BrowserFile will give you the name of the file as it was uploaded.?
If not, what should I be doing.
What should I call to get handle, and what should I call to get the actual filename ?
Well, what you have been doing works fine for getting the file handle, but you can also get it from; $Request->FileUpload('upload_file', 'FileHandle');I am sooo confused !Originally, the file upload interface was only available through doing it as you do with my $fh = $Request->Form('upload_file') but as users needed more of the file upload info, I created the FileUpload collection to store more of the data. Originally MS ASP did not have any native file upload support, so I had not API to emulate here, and had to make it up as we went.
I have one further query. If I do the following.. (where "filename" is the name of the file upload box on the html page) :
my $newFileHandle = $Request->Form('filename');
my $newFileName = $Request->FileUpload('filename','BrowserFile');
Is that the correct syntax ?
I mean it appear to work, but I still notice something slightly strange.
If I print them both, they both show the same :
my $newFileHandle = $Request->Form('filename');
print "file handle: $newFileHandle <br>";
my $newFileName = $Request->FileUpload('filename','BrowserFile');
print "name: $newFileName <br>";
... this gives :
file handle: points.doc
name: points.doc
If I print to Data::Dumper as follows :
print Dumper $newFileHandle . "<br>";
print Dumper $newFileName . "<br>";
I get the following output....
file handle: $VAR1 = bless( \*{'Fh::fh00003points.doc'}, 'Fh' );
name: $VAR1 = bless( \*{'Fh::fh00003points.doc'}, 'Fh' );
So, what is the difference.
When I ask for "browserFile" from the FileUpload request object, why is it still a file handle ?
Maybe I am just being incredibly stupid, but I dont see any difference to doing it this way, as to the way I was initially doing it.
Richard
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]