0

This really is two questions in one since they are both faces of the same coin :) ...

1) How can I upload a file to a servlet from an application/service, in other words without a html form that a user should fill in?

2) On the receiving end, I have used Apache FileUpload before, but this handles form inputs, is there another way to handle an upload not coming from a form?

Thank you for your help

Jonny

  • I went with the Java code found in this post [here](http://stackoverflow.com/questions/1067655/how-to-upload-a-file-using-java-httpclient-library-working-with-php-strange-pr) as a starting point. It works a treat. – user2511552 Jun 26 '13 at 09:40

1 Answers1

0

1) How can I upload a file to a servlet from an application/service, in other words without a html form that a user should fill in?

You have to create a HTTP request containing the correct headers (multipart/formdata) that contains the file you want to upload. Have a look at this post: Upload files from Java client to a HTTP server. I haven't tried it, but it looks as if it could work.

2) On the receiving end, I have used Apache FileUpload before, but this handles form inputs, is there another way to handle an upload not coming from a form?

You should still be able to use Apache FileUpload on the receiving end since it merely parses the HTTP request which should still be formatted in the same way.

Community
  • 1
  • 1
Tom
  • 3,913
  • 19
  • 28