On Fri, Oct 14, 2005 at 04:50:34PM -0400, Cees Hek wrote:
> That 'feature' of CGI.pm is very annoying, and cost me a couple days
> of frustration to get it to work properly for my

Ah!  I hoped someone had done all the painful work for me.

> The solution is surprisingly short (I orginally wrote simple here, but
> I can't say that word really fits for this odd and annoying
> situation):
> 
> my $fh = $query->upload('filename');
> my $real_fh = \*$fh;o

That doesn't seem to work for me:

  use Data::Dumper;
  my $cgi_fh = $self->query()->upload('File');
  warn Dumper($cgi_fh);
  my $fh = \*$cgi_fh;  # work around CGI.pm's Fh implimentation
  warn Dumper($fh);
  $fh = wraphandle($fh);
  warn Dumper($fh);
  my $csv = Text::CSV_XS->new({quote_char => '~', binary => 1});
  my @columns = $csv->getline($fh);

results in:

$VAR1 = bless( \*{'Fh::fh00001unregprovidertest.dat'}, 'Fh' );
$VAR1 = bless( \*{'Fh::fh00001unregprovidertest.dat'}, 'Fh' );
$VAR1 = bless( \*{'Fh::fh00001unregprovidertest.dat'}, 'Fh' );
[Fri Oct 14 17:19:19 2005] [error] Error executing run mode 'Upload': Undefined 
subroutine Fh::getline

> For a usage example look at the above mentioned
> Data::FormValidator::Filter::Image and see what other hoops I had to
> jump through to create my own new Fh object to return to the user, so
> that things continue to work as CGI.pm intends.

(views code)
Wow, that was a dedicated effort.

Incidentally I see:

 return $fh unless $fh && ref $fh eq 'Fh';
 my $filename = $fh->asString;
 $filename =~ s/^.*[\/\\]//; # strip off any path information that IE puts in 
the filename
 binmode $fh;
 
 my ($result, $image);
 eval {
     $image = Image::Magick->new;
     $result = $image->Read( file => \*$fh );
 };

Which matches what you told me, but doesn't do the trick for me. :(
Also, I don't seem to find $filename used anywhere...did I miss it?

I'm actually entertaining the idea of using an Acme module, but Acme::Damn
doesn't pass it's tests on my dev box. :( 


-- 
SwiftOne  /  Brett Sanger
[EMAIL PROTECTED]   

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to