Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open file, submit to script?

Status
Not open for further replies.

Kiehlster

MIS
Joined
Aug 14, 2000
Messages
147
Location
US
I'm trying to make a script so that I can use the windows "send to" menu to automatically upload a selected file to a webpage. I can get the filename and everything, but I can't turn that filename into a stream to that file. I also can't get the file dialog in an html form to preset a value. Can someone show me how I can pass a file, username and password from a local script to a remote script?
Steve Kiehl
webmaster@nanovox.com
 
The best way I've found to call a remote script from a local script is to the the LWP and user agent modules. You can build a query to the remote script, send it, and get the results back. Here's an example of how it's done:
Code:
use URI::URL;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;

# Set up form parameters
my %form = ();
%form = ( FUNC => $func, Name => $name );

# Build the request and send it
my $tmpurl = url("http:");
$tmpurl->query_form(%form);
my $req = new HTTP::Request 'POST', "[URL unfurl="true"]http://www.remotesite.com/cgi-bin/remoteprog.pl";[/URL]
$req->content_type('application/x-[URL unfurl="true"]www-form-urlencoded');[/URL]
$req->content($tmpurl->equery);

# Check the results
my $res = $ua->request($req);
if ( $res->is_success ) {
   $returnData = $res->as_string;
} else {
   $ErrorMsg = "HTTP error: " . $res->code . " " . $res->message;
}
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top