Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 191149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:19:00+00:00 2026-05-11T16:19:00+00:00

I’ve just written (in Perl) a simple web service that displays a web form

  • 0

I’ve just written (in Perl) a simple web service that displays a web form containing a single “file” type upload field and a single Submit button. I made this simple web page with the intent that a human could use it and also that a script on a different machine could also execute it programatically. I got the human part all done and tested and now I just realized that I have no idea how to construct a URL on the second machine that successfully executes this cgi script on the first machine (and gets a file uploaded from the second machine to the first machine).

I do have some experience constructing URLs that contain form fields, but have never used the “file” type upload input field before, so I’m struggling with it a bit. Maybe I’m using it wrong.

If my simple web service is a cgi-bin script called “myscript.pl” and if the file upload field is called “uploadthis” and if the file on the second machine that I want to upload programatically is located in “C:\myfile.txt”, then shouldn’t I be able to just construct a URL in a script on the second machine of the form “http://machine1/cgi-bin/myscript.pl?uploadthis=C:\myfile.txt” and that file gets uploaded programatically just as if a human had clicked on the browse button on the web form manually and chose that file and clicked on the Submit button?

It works fine manually when I bring up the cgi script form on the first machine and browse to the file and click Submit. The file seems to get uploaded by the web browser just fine. But when I type in the above URL into my browser to test out the file upload URL manually before I program that URL into a script on another machine, the file that gets uploaded is a zero length file. It creates a file but it’s completely empty. Same results if I use a known bad filename like “http://machine1/cgi-bin/myscript.pl?uploadthis=C:\myfilethatdoesntexist.txt”. What am I doing wrong?

I’m trying to accomplish this task on a couple of Windows XP PCs with Apache 2.2 and ActivePerl 5.10.0 and the form method is “post”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:19:00+00:00Added an answer on May 11, 2026 at 4:19 pm

    The phrase “multipart/form-data” was something that I had missed completely. When I Google’d that phrase, I found my answer.

    Something similar to this example below is how I solved my problem from a perl script:

    use HTTP::Request::Common;
    use LWP::UserAgent;
    
    $ua = LWP::UserAgent->new;
    
    my $response = $ua->request(
        POST 'http://machine1/cgi-bin/myscript.pl',
        Content_Type => 'form-data',
        Content      => [ 
                            uploadthis => ["C:\myfile.txt"],
                        ]
        );
    
    if ($response->is_success) {
        print "Success.";
    }
    else {
        print "Failure.";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.