It's not a secret anymore!
The moose likes Sockets and Internet Protocols and the fly likes Implementing file upload like CURL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Implementing file upload like CURL" Watch "Implementing file upload like CURL" New topic

Implementing file upload like CURL

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
My client has some CGI solution to uploading files in your server. Is a perl script who deals with curl clients, sending requests with files to upload.

In Curl manual (, the solutin for upload files is described as using -F clause, "This causes curl to POST data using the Content-Type multipart/form-data according to RFC1867"

I try to use HttpClient and solutions, and I write some code. But I had two problems:
-> In some cases, parameters ('action', 'filename', etc) are not readed from CGI
-> If parameters was loaded OK, the file was not found !

My first code, using HttpClient (based in PostMethod class to do the POST):

My next try was to write in an outputstream:

In this two examples, parameters are readed, but not the file.
Because the perl CGI reads the file as standard in (some like "$_"), I don�t know how this solution could be implemented.

Has someone leads with curl or another similar solution (in CGI) to uploading files ?
I agree. Here's the link:
subject: Implementing file upload like CURL
It's not a secret anymore!