in reply to Re: How do I upload a file to a https server.
in thread How do I upload a file to a https server.

Thanks for your help. I have tried the following which uses 'post' directly and not 'request' as in your code:
my $browser = LWP::UserAgent->new; ... my $response = $browser->post($url, [ 'file' =>[ "/tmp/test_file.txt" +] ]);
I get "405 Method not allowed". Does something need configuring on the server or is the code wrong? (I have tried http and https servers). Thanks Jonathan

Replies are listed 'Best First'.
Re: Re: Re: How do I upload a file to a https server.
by iburrell (Chaplain) on Jun 01, 2004 at 23:50 UTC
    That error code is coming from the server. It means that the server does not allow POSTs to that URL. Most likely, the URL you are posting to is not a script. POST uploads need a script that handle processing the form submission and saves the uploaded file.

    PUT is the other method to handle uploads. The web server must be configured to handle this. It puts the upload over the URL.

      Hi
      Thanks for your previous help with this everybody but I still can't get this to work.
      This is the form on the server:

      <form action="https://<address>/cgi-bin/upload.pl" method="post" enctype="multipart/form-data">

      <input type="File" name="FILE1" size="40">
      <input type="File" name="FILE2" size="40">
      <input type="File" name="FILE3" size="40">
      <input type="File" name="FILE4" size="40">
      <input type="File" name="FILE5" size="40">
      <input type="File" name="FILE6" size="40">
      <input type="File" name="FILE7" size="40">
      <input type="File" name="FILE8" size="40">
      <input type="File" name="FILE9" size="40">
      <input type="File" name="FILE10" size="40">

      <input type="Submit" value=" Upload " >  <input type="reset" value=" Reset ">


      This is my code (I have tried many variations of this):

      my $url = 'https://<address>/cgi-bin/upload.pl'; my $response = $browser->post($url,Content_Type => "multipart/form-data" Content => [file => ['data.txt']]); print ($response->status_line);
      I get an "OK" response but the file never gets to the server. Can you see anything wrong?

      Thanks

      Jonathan