gtdopa.blogg.se

Curl multipart form
Curl multipart form












curl multipart form

curl multipart form

The jsp response was the paragraph of text resulting from the audio. In our case we were posting a WAV file among other user information to a transcription service (audio to text). Alternative solution to resolve this issue is to add support for multipart/form-data on java server using common’s ServletFileUpload We hope this would help other developers to resolve this type of issue. send the parameters in urlencoding string as we have http servlet on the java server side. Later we realized that java server is not unmarshalling the post data(mutipart/form-data) which is in array format from php curl. We read many articles and documentations but there were no solution for this problem. So it was the time we ask our friends google and stackoverflow.

#Curl multipart form code

We create a php script which just listens the request and print all the parameters in the log file.We used the above code and we were able to extract the parameters from the request. We tried to investigate the problem and our first suspicion was that the php curl is not working properly. We were using the following code to post form data to java server: define("URL","") Ĭurl_setopt($ch, CURLOPT_POSTFIELDS, $fields) To our surprise, data was not captured by java server. In this case, cURL adds the Content-Type header, but with a multipart/form-data value instead. Similar to the -data option, this lets cURL simulate a user sending a filled in HTTP form by pressing the submit button. We tried to use the php curl and used array to send the data to server. To upload a file using cURL you can use the -F, -form command-line option. Simple stuff !!! right ? Well not exactly. We can use the php curl and post the data to java server. We thought it would be simpler task as we need to fetch data from mysql database and need to do http post to the java server. Recently one of client come up with the requirements to post data from php platform to java platform.














Curl multipart form