im doing validations in java code for image upload..im unable to get validated i.e.,if two files are entered it should check for the dimensions.i m unable to code how to check for the dimensions...can anyone help me out...here is the code...
Rob Prime wrote:Since I know absolutely nothing of your ImageContentData I cannot tell you how to read the dimensions of an image that is apparently contained in it. TellTheDetails.
The response should make it clear how images are stored in class ImageContentData; we may then be able to suggest how to obtain image dimensions.
Lester and Rob are very much right in their own way. Your question is very specific to a class which would not make sense unless the reader has some background of that.
Anyways...what I could make out on my own is, you have two images and you want to compare them for their height and width.
If I my udnerstanding of your probolem is correct you should see java.awt.Image class.
Pl correct my if I got you wrong.
im doing application in which im uploading images for suppose im uploading 2 images at a time.I need to check the following conditions
1)check if uploaded images had Duplicate File Name...if i has same File Name..then it should throw an error.
2)check if uploaded images had Duplicate Dimensions...if i has same File Name..then it should throw an error.
and i coded in the following java files
i m not getting idea how to check the conditions for validations in isValidImageContent() method...can any one help me out..
e.g. your ContentProperties does not make any sense to me.
you mentioned you want to validate image name and dimension but I dont see that in the code posted. Moreover, I am yet to understand your problem.
Please go through the link provided by Rob TellTheDetails.
i got what you suggested..im developing mobile application.In which user can upload image from internet to his mobile...im writing code if user uploads 2images that should validated...i need to write in for loop..im not getting idea how to check 2 images are same or not...that is my problem..can you suggest me how to code it..
i had done some validation in uploading my image for my mobile application...im unable to check whether the file is uploaded or not...i used System.out.println statement for verification..but im not getting...can anyone check it and provide me the solution..here is the code and im using console application..
madhuri kunchala wrote:
These conditions will always evaluate to true, so they're most likely not what you intended to do.
Also, having "imageContentData.getFileBytes() != null" trigger the "Duplicate File Name" case looks suspicious; did you mean to use "&&" instead of "||"?
Lastly, "imageContentData.getType().trim()" (and the following ones) will never be null, so the check for null is bogus. "imageContentData.getType()", however, could conceivably be null, in which case the "trim()" call would throw an exception. You probably want to check "imageContentData.getType() != null" instead.
Lester Burnham wrote:Have you addressed the first point of my previous post? It's crucial, as is imageContentDatas not being empty.
madhuri kunchala wrote:..the ImageContentDatas is an ArrayList and it cant be empty
If it can't be empty, then why is there code that checks whether it's empty and creates an error message if it is?
I'm getting the idea that you're not going about this very methodically. At this point I think it would be faster if you inserted System.out.println statements between each two lines of code, and print the values of all variables. Then you'll know how the code behaves and why. (It may be easier to do this using a debugger in your IDE, if you're using one.)