On Feb 12, 2008 8:43 AM, Brent Clark <[EMAIL PROTECTED]> wrote:
> Hi
>
> Heres my silly Q for the day
>
> I would like to upload a xml file, and would like the file to sent directly
> to XMLin().
>
> Im trying to find a way of not have to create the file in /tmp, and heres my
> working code.
>
> my $filename = $cgi->param("filename");
> #my $filename =~ s/.*[\/\\](.*)/$1/;
> my $upload_filehandle = $cgi->upload("filename");
snip
> #my $xs = new XML::Simple( keeproot => 1, forcearray => 1);
> #my $ref = $xs->XMLin( "$upload_dir/$filename" );
> my $ref = $xs->XMLin( <$upload_filehandle> );
> my $xml = $xs->XMLout($ref);
> print $xml;
snip
The XMLin method takes a string, file, or file handle as its argument.
Just pass $upload_filehandle to it:
my $ref = $xs->XMLin($cgi->upload("filename"));
print $xs->XMLout($ref);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/