Here is the code

use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;

{
    package RequestAgent;
    @ISA = qw(LWP::UserAgent);

    sub new
    { 
        my $self = LWP::UserAgent::new(@_);
        $self->agent("lwp-request");
        $self;
    }

    sub get_basic_credentials
    {
        my($self, $realm, $uri) = @_;
        if( $realm eq "www.uploadsite.com" )
        {
           return("uploadUSER", "uploadPWD");
        }
        return ("proxyUSER","proxyPWD");
    }
}

my $agent = new RequestAgent();
$agent->proxy( http=>'http://proxy.com');
$agent->timeout( 3600 );

my $file = $ARGV[ 0 ]; 
        
my $response = $agent->request( 
        POST 'http://www.upload.com/upload.pl',         Content_Type
=> 'form-data',                 Content  => [ Button  => 'Submit',              
             myFile   => ["./$file",$file ],                         ]
        );
if( $response->is_error() )
{
        print $response->code();
}

Thanks

Jack
--- Gisle Aas <[EMAIL PROTECTED]> wrote:
> Steve Sapovits <[EMAIL PROTECTED]>
> writes:
> 
> > The only thing I've ever personally seen affect
> > this is the timeout value. 
> > 
> > Test the time to failure:  If it's failing after
> > 3600 seconds you still have a timeout that's too
> > small (probably).  If not, then you're hitting 
> > something I have not seen.  I regularly uploaded
> > very large files using the same methods I sent out
> > in my example.
> 
> The timeout you set is used as timeout between
> activity on the wire.
> There should not be a need to set up a long timeout
> just because you
> are uploading a big file.
> 
> and I have no idea what the original problem might
> be.  Some real code
> that fails might be useful.
> 
> Regards,
> Gisle
> 
> > 
> > ----
> > Steve Sapovits
> > Global Sports Interactive
> > Work Email: [EMAIL PROTECTED]
> > Home Email: [EMAIL PROTECTED]
> > Work Phone: 610-491-7087
> > Cell:       610-574-7706
> > Pager:      877-239-4003
> > 
> > > -----Original Message-----
> > > From:     Jack Yang [SMTP:[EMAIL PROTECTED]]
> > > Sent:     Monday, December 17, 2001 1:34 PM
> > > To:       [EMAIL PROTECTED]
> > > Cc:       [EMAIL PROTECTED]
> > > Subject:  500 error and upload
> > > 
> > > I have a perl script which is used to upload
> file.  It
> > > runs well if I upload a relatively small size
> file,
> > > but as soon as the file size is over 10K I will
> > > encounter error 500.  If I use the IE5.0 to do
> the
> > > upload, I will have no problem to upload the big
> size
> > > file.
> > > 
> > > I am using the HTTP::Request::Common to do the
> upload,
> > > and I have increased the timeout to be 3600
> seconds. I
> > > have the correct setting for the proxy server
> since I
> > > can upload small file successfully.  
> > > Any idea about why big size file can't be
> uploaded? 
> > > 


__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

Reply via email to