commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <simon.kitch...@chello.at>
Subject Re: get image dimensions before upload?
Date Thu, 13 Dec 2007 15:55:41 GMT
As far as I know, there is no way to "read the image header" on a remote file.

File upload controls are pretty primitive things. All you can do is include in an html page
a tag that tells the remote browser that it should provide some kind of button which, when
clicked, allows the user to choose a file. When the enclosing form is submitted, the browser
will then post back to the server the form AND the contents of the selected file. The name
of the file is also usually available, in the mime headers of the posted data.

If I remember right, the tag also allows a filename filter pattern to be provided.

That's all the control the writer of the web page has. AFAIK there is no way to request part
of the file the user selected, or any other data about the file. There is also no way to control
what file the user chooses to send.

Regards,

Simon

---- xiaofeng <enderwiggin.rimer@gmail.com> schrieb:
> only read the image header then you can determine the dimension of the
> image.
> 
> On Dec 13, 2007 9:01 PM, loredana loredana <loredana888888@yahoo.com> wrote:
> 
> > Hi, i'm new to this list. I have a question. I have a page where a user
> > can upload a image on the server. The way I did it was pretty basic:
> >
> >        boolean isMultipart = ServletFileUpload.isMultipartContent
> > (request);
> >        FileItemFactory factory = new DiskFileItemFactory();
> >        ServletFileUpload upload = new ServletFileUpload(factory);
> >        List items=null;
> >        items = upload.parseRequest(request);
> >        Iterator iter = items.iterator();
> >        while (iter.hasNext()) {
> >            FileItem item = (FileItem) iter.next();
> >            File uploadedFile = new File("image.gif");
> >            item.write(uploadedFile);
> >
> > I need to make sure that the image the user uploads is of height 150 and
> > width 100 ....I can probably do that by saving the uploaded file, check the
> > dimensions and delete it in case it's doesn't have the necesary size. But is
> > there a way to check this before the file is uploaded? 10x
> >
> >
> >
> >
> >
> >  ____________________________________________________________________________________
> > Be a better friend, newshound, and
> > know-it-all with Yahoo! Mobile.  Try it now.
> > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > For additional commands, e-mail: user-help@commons.apache.org
> >
> >
> 
> 
> -- 
> >_<


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message