• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get height and width of uploaded image

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am building a web app that allows the user to upload images.
They are then displayed in a grid, and they must fit inside their box, so one dimension fits the box and the other is scaled.
To do that I store the image in the DB.

It was working fine on my laptop, because I have access to the file system. Once I uploaded it on the servers of a hosting company it stopped working, because there is no access to the file system.

They also provide an FTP directory, so I changed my app to FTP files to that directory. Now it doesn't work anymore.
Here's what I am doing, if anybody can spot what is wrong, I would appreciate. Thanks in advance...

I am using commons.fileupload and commons.net



No exception is thrown at



but image is null, and I get a null pointer exception when I try to get width and height.

I am sure that the InputStream object is not null or corrupted because it's FTP'ed ok, and it can be opened from the remote location.

Reading the image from the file system is not an option...

Thanks!

 
Dan Arbo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found a solution, in case anyone ever has the same problem, using AWT BufferedImage.

FileItem fileItem is the image returned by the form which uploads the file

 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pretty good for a greenhorn
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic