my dog learned polymorphism*
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
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Implementing file upload like CURL" Watch "Implementing file upload like CURL" New topic
Author

Implementing file upload like CURL

Anonymous
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 (http://www.hmug.org/man/1/curl.php), 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 java.net 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 ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Implementing file upload like CURL
 
Similar Threads
Upload/download file
How to upload a file from applet to the webserver ?
File Permission Error
Translating JAVA code to VBA (excel)
HttpClient file upload code review