Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

uploading files with java

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just wondering, is there some way in java to upload a file to the internet?
I have one of those free web pages (you know, with the advertisements). Anyway, the way I usually upload a file, is I go to the internet site of my page and click a button and choose a file and then click another button to upload it. But even though I want to upload a lot of files, I can upload only one file at a time. So I have to spend hours just clicking file icons. So I wonder, is there any way to write a java program that will do this for me?
One way this can be done is to to write a java program that will start up the internet browser and click buttons and click items in a list. I don't know if java programs can do that or not.
A more direct way, I suppose, is to write a program that will upload files directly, without even needing a browser. But I guess I would need some special password or access or something.
Maybe there is some other way to do it. I don't know. I've written a lot of java, but I'm clueless about how java works on the internet.
 
Sheriff
Posts: 22662
127
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out Apache's HttpClient library.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apache Commons - FileUpload Control

 
Marshal
Posts: 27280
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kerry Bear wrote:Apache Commons - FileUpload Control



But that's code to run on the server, when somebody uploads a file to it. Sounds like Kevin's requirement is on the client side.
 
Paul Clapham
Marshal
Posts: 27280
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:Check out Apache's HttpClient library.



Yep, this is the code to use. But don't think of it as "pressing buttons". That's what you have to do to make a browser upload a file, but what the browser is actually doing is sending HTTP requests and receiving HTTP responses. Your task is to identify the requests being sent and to replicate them in your Java code. The HttpClient library helps you to do that without also having to learn the tedious details of the HTTP protocol.
 
Kerry Baer
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could write a java applet that would run on the client end. You may have to resort to FTP by doing so (someone please confirm - I don't have much experience writing applets)
 
Rob Spoor
Sheriff
Posts: 22662
127
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not going to help Kevin, as a) it's an existing web application, and b) he's not hosting it, he's using it.
reply
    Bookmark Topic Watch Topic
  • New Topic