Trouble auto-submitting a form with CURL
- From: laredotornado <laredotornado@xxxxxxxxxxx>
- Date: Thu, 3 Apr 2008 16:05:20 -0700 (PDT)
Hi,
I want to use PHP to auto-submit a form with a file input. Here is
the form's source:
<html>
<head></head>
<body>
<form enctype="multipart/form-data" name="f" method="post"
action="updateprices.php">
Price File <input type="file" name="pricefile" id="pricefile" /
<br><input type="submit" value="Submit" />
</form>
</body>
</html>
but when I attempt this code, I don't get my desired results. Here's
the code:
$postData = array();
$url = "http://mydomain.php/updateprices.php";
//simulates <input type="file" name="pricefile">
$postData[ 'pricefile' ] = "/tmp/test.csv";
$postData[ 'submit' ] = "Submit";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1 );
//seems no need to tell it enctype='multipart/data' it already knows
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );
$response = curl_exec( $ch );
print $response;
and here's the result:
Notice: Undefined index: pricefile in /usr/local/apache2/htdocs/
super_admin_rs/updateprices.php on line 4
Any ideas where I'm going wrong?
Thanks, - Dave
.
- Follow-Ups:
- Re: Trouble auto-submitting a form with CURL
- From: Jerry Stuckle
- Re: Trouble auto-submitting a form with CURL
- Prev by Date: File Removal after Database Comparison
- Next by Date: Re: CMS tutorial?
- Previous by thread: File Removal after Database Comparison
- Next by thread: Re: Trouble auto-submitting a form with CURL
- Index(es):
Relevant Pages
|