Am 17.12.2006 um 01:42 schrieb C.G. LEE:
Hi,
I am swimming in the pool, file uploading.
I used the Jifty::Web::Form::Field::Upload for a client to upload a
file, and I got a file handle in my model as below:
sub create{
my $self = shift;
my %args = (@_);
$fh = $args{'upload_file'};
...
}
the uploading was good(the file handle worked as I expected). Then
how do I get file name and extension of an uploaded file?
I saw the docs of Jifty::Web::Form::Element and
Jifty::Web::Form::Field, but not yet...
depending on the context you use your $fh variable above, you will
either use it as a filehandle or get the filename back.
# this reads the file:
while (my $line = <$fh>) {
# do something
}
# this gets the name (scalar context forced for readability here)
my $filename = scalar($fh);
However, there is no guarantee about how you will get the filename.
Some platforms (eg. Windows with Explorer) will give you the full
path with "\" as a path separator and a drive letter, other platforms
may only tell you the filename without any directory names...
Grüße,
Wolfgang Kinkeldei
--
' /\_/\ ' .print[split??,"".(($/=q|Cms)+-03467:;<=|)=~tr!C-z -B! -z!)x
'( o.o )' .$/]->[hex]foreach split qr<>,qq+1ecd039ad65b025b8063475b+||
' > ^ < ' .q<!-- Wolfgang Kinkeldei - mailto:[EMAIL PROTECTED] -->
Grüße,
Wolfgang Kinkeldei
--
' /\_/\ ' .print[split??,"".(($/=q|Cms)+-03467:;<=|)=~tr!C-z -B! -z!)x
'( o.o )' .$/]->[hex]foreach split qr<>,qq+1ecd039ad65b025b8063475b+||
' > ^ < ' .q<!-- Wolfgang Kinkeldei - mailto:[EMAIL PROTECTED] -->
_______________________________________________
jifty-devel mailing list
[email protected]
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel