aspose file tools*
The moose likes Servlets and the fly likes uploading images and java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "uploading images and java" Watch "uploading images and java" New topic
Author

uploading images and java

Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 250
    
    1
I'm thinking of starting a new project but I'm unsure whether I should use Java. It's a web application that allows people to build a quiz and I want the user to be able to add questions and images. Can you upload images in Java? Can the program then make use of that image? I figured that because the image isn't already in the jar (and in the right directory) then it can't be used by the program.

I wondered whether I could store any images in a central database and access them this way? is this difficult? Having this data separate in a database might make it easier to produce Android and iphone apps if I went that far (I probably won't). I could write the application in PHP but then I'd lose some functionality.

Any thoughts?

Mike


Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Yes, a web app powered by Java can upload and use images. It has nothing to do with jar files, of which many go into constructing a web app.

See the JSP and servlets FAQs fOr more info.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
gurunath pai
Greenhorn

Joined: Dec 10, 2012
Posts: 13

Its your call to decide which technology you want to use to develop a application, most of the things are supported in most of the technologies.


“Anyone who has never made a mistake has never tried anything new.” ― Albert Einstein
Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 250
    
    1
Thanks for the input guys.

With the jars I have produced so far I can only access images that are in the current jar (ie already zipped up) or in the source directory of the jar. I presume you're saying a java app/applet can input an image and store it in it's home directory so that other users can use it? Can you point me at an example or a slightly longer explanation as to how to do this (or even some keywords I can google ). Cheers.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Web apps are fronted by HTML, usually produced by JSP templates. Images are not read from jar files, but are accessed by <img> elements in the HTML.

Are you sure it's a web app you want to write? It doesn't seem like you've got a good handle on how to approach that.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

With regards to file uploading, see the JspFaq and ServletsFaq for starters.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

You can do what you are asking, but as @bear asks, are you sure you have thought out the architecture for this?

Concerning storing images on your server, you have many choices. You can simply store the images as files that your webserver (apache, etc.) can read, or you can store the bytes of the image in a blob in your favorite database table in a DBMS (mysql, sqllite, oracle, etc.). Which you select is simply an engineering design question, there are pros and cons of each.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: uploading images and java