Hello,
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 data. 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: id=59983747523345--curlPIKMeVU5z20345 Content-disposition: form-data; name=\"version\" version=1.1--curlPIKMeVU5z20345 Content-Disposition: form-data; name=\"ref\" ref=none--curlPIKMeVU5z20345 Content-Disposition: form-data; name=\"queryMethod\" queryMethod=accession .... 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_URL,$url); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_VERBOSE,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$post); curl_setopt($ch, CURLOPT_INFILE,$uf); curl_setopt($ch, CURLOPT_INFILESIZE, $HTTP_POST_FILES['file1']['size']); curl_setopt($ch, CURLOPT_VERBOSE, 1); $res = curl_exec($ch); $result_array = curl_getinfo($ch); $result_array{"CONTENT"}=$res; curl_close($ch); I think this is straightforward Open the file that was uploaded. init curl. set CURL_INFILE to the file pointer Pass an array ($post) including the file (@tmp_name) and other post arguments -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php