I have a form with a file upload field (named 'file1') and a number of
other data fields for submission.
I am attempting to use curl to take the user submitted data, add some
additional data, submit it to another location, retrieve the response
and send that response back to the user that originally submitted the
I have set up a test environment and have been unable to see all of the
pieces succeed at the same time. (Either I get the form fields or the
file, but not both).
I am using PHP 4.2.1 with libcurl 7.9.4 with Apache 1.2.24 on Linux.
phpinfo() reports some interesting facts (as always)
It seems that the _POST array is gobbling up portions of the form-data
without respect to the boundaries.
In other words, I see an entry for $_POST["id"] and the value for that
array element includes the encoded content for the id, version, ref and
queryMethod arguments including the boundary indicator and mime headers.
The value for $_POST["id"] would be:
Content-disposition: form-data; name=\"version\"
Content-Disposition: form-data; name=\"ref\"
Content-Disposition: form-data; name=\"queryMethod\"
.... and so on through the entire multipart request including file.
Here is the bit of curl via php that is at the center of my dillema:
$url = "http://192.168.254.211/asp/test20020521/file/filetest.php";
$uf = fopen($HTTP_POST_FILES['file1']['tmp_name'],'r');
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$res = curl_exec($ch);
$result_array = curl_getinfo($ch);
I think this is straightforward
Open the file that was uploaded.
set CURL_INFILE to the file pointer
Pass an array ($post) including the file (@tmp_name) and other post
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php