perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Chamas <j...@chamas.com>
Subject Re: Another stupid question...
Date Tue, 11 Feb 2003 00:20:43 GMT
Richard Curtis wrote:
> 
> 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.

Regards,

Josh

________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Mime
View raw message