Trouble auto-submitting a form with CURL



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
.



Relevant Pages

  • Re: Trouble auto-submitting a form with CURL
    ... I want to use PHP to auto-submit a form with a file input. ... curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); ...
    (alt.php)
  • Re: Postdata.att
    ... Front Page needs to install some additional software for ... Mike - http://pages.prodigy.net/michael_santovec/techhelp.htm ... I have a PC that create a blank e-mail without the Postdata. ... same html file executed in another computer creates the postdata ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)