Hi all,

I have a task at hand , that of uplaoding file from server to another server
and also pass 6 paramteres along with the file.

Basically, I have to te the functionality provided by CFHTTP tag of
COLD FUSION.

I used LWP::UserAgent for the purpose.
My Program is given below.

#!usr/local/bin/perl
use LWP::Simple;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request::Common qw/POST/;

LWP::Debug::level('+') ;

push(INC, '/opt/customer/apps/sun-83/nes363/suitespot/cgi-bin/lib/LWP/') ;
my $ua= LWP::UserAgent->new;
my $file="/home/hewebadm/nilay/test1.txt" ;
my $filename="323272-1980-test1.txt" ;
open(READFILE, "<$file") ;
data=<READFILE> ;

# HAve to post the content at this URL #
my $url="http://downloaddev.pearsoncmg.com/extmanage/extpost.php" ;

# Have hard coded the parameters #

$request = POST $url,
Content_Type => 'application/x-www-form-urlencoded',
Content => [ action => "insert",
file => "data",
filename => "$filename",
parentisbn => "0131406701",
linktext => "test1.txt",
type => "Presentations",
imprint =>"ph" ,
secret =>
"08ER0L%29N04P73N9%3ACW%2ANC%5F%250%20%0A" ,
] ;

my $results=$ua->request($request );

print Dumper($results);
if($results->is_success){
print $results->as_string() ;
print $results->status_line();
}

On executing this program, I am supposed to get back a URL from the site :
[url]http://downloaddev.pearsoncmg.com/extmanage/extpost.php[/url]

But I am getting ERROR: <BR> instead.

Here is the output of the program:
!perl cp_try_lwp.pl
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: POST
[url]http://downloaddev.pearsoncmg.com/extmanage/extpost.php[/url]
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 12 bytes
LWP::UserAgent::request: Simple response: OK
$VAR1 = bless( {
'_protocol' => 'HTTP/1.1',
'_content' => 'ERROR: <BR>
',
'_rc' => '200',
'_headers' => bless( {
'connection' => 'close',
'x-powered-by' => 'PHP/4.2.2',
'client-response-num' => 1,
'date' => 'Sat, 31 Jan 2004 10:57:02
GMT',
'client-peer' =>
'209.202.161.174:80',
'client-date' => 'Sat, 31 Jan 2004
10:57:04 GMT',
'content-type' => 'text/html',
'server' => 'Apache/1.3.20 (Unix)
PHP/4.2.2',
'client-transfer-encoding' =>
'chunked'
}, 'HTTP::Headers' ),
'_msg' => 'OK',
'_request' => bless( {
'_content' =>
'action=insert&file=abcsssss%0A+sad%0A+asd%0A+asd% 0A+asd%0A+asd%0A+asda%0A+s
das%0A+dasd%0A+fsdf%0A+sdf%0A+sdf%0A+sdf%0A+sdfa%0 A+dfasd%0A+fas%0A+dfas%0A+
dfs%0A+df%0A+sdf%0A+f%0A&filename=323272-1980-test1.txt&parentisbn=013140670
1&linktext=test1.txt&type=Presentations&imprint=ph &secret=08ER0L%2529N04P73N
9%253ACW%252ANC%255F%25250%2520%250A',
'_uri' => bless( do{\(my $o =
'http://downloaddev.pearsoncmg.com/extmanage/extpost.php')}, 'URI::http' ),
'_headers' => bless( {
'user-agent'
=> 'libwww-perl/5.76',

'content-type' => 'application/x-www-form-urlencoded',

'content-length' => 339
},
'HTTP::Headers' ),
'_method' => 'POST'
}, 'HTTP::Request' )
}, 'HTTP::Response' );
HTTP/1.1 200 OK
Connection: close
Date: Sat, 31 Jan 2004 10:57:02 GMT
Server: Apache/1.3.20 (Unix) PHP/4.2.2
Content-Type: text/html
Client-Date: Sat, 31 Jan 2004 10:57:04 GMT
Client-Peer: 209.202.161.174:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
X-Powered-By: PHP/4.2.2

ERROR: <BR>

200 OK
ERROR: <BR>

I want to know, if I am able to talk to the php program , (since if I do not
pass the paramnteres, I am prompted with the error of missing paramteres.)
what is wrong with this piece of code ?

And I have no access to the php program.

And I can't suspect the php program to be wrong as the same php program when
called thru Cold fusion program is able to upload the file successfully.

NOTE : I have tried passing the file name as well file data in the line :
file => "data",

Please guide me.

Thanks