views:

47

answers:

2

Hi,

Is there any Jquery Plugin to perform the image dimension operation on an image before being uploaded using uplodify. i want the plugin to check the image dimension with the fixed define size and then only process for uploading.

right now i am doing it with PHP function, instead of server side validation i want to adopt the client side validation.

+1  A: 

I do not believe that this is possible, since JavaScript is not allowed to access the local filesystem (for security reasons).

elusive
i am talking about something like this, i am unable to understand it properly as still i am beginner for javascript..
Ibrahim Azhar Armar
http://gugod.org/2007/12/jquery-way-to-limit-image-size.html
Ibrahim Azhar Armar
@Ibrahim That's only applying some simply CSS to images that the browser has already loaded. As elusive said though, images that are not loaded, but are only present as files on the hard disk, can't be accessed through Javascript. You will need some plugin (Flash, Java) to do that.
deceze
@Ibrahim: That algorithm iterates over images already downloaded *from the server* and has nothing to do with what you're asking. – @elusive: Yes, it is possible, see the demo I posted in a comment on the question.
Marcel Korpel
@deceze: No, you don't need a plugin for that with the canvas element and the File API.
Marcel Korpel
@Marcel Korpel: You are right, it is possible to figure out the size of a _loaded_ image. You cannot load files from the local filesystem though.
elusive
Did you look at the demo? It uses the File API to load the image from the local filesystem inside a canvas element *before uploading*. Moreover, it checks the width of the image.
Marcel Korpel
This is interesting. It is really clever to use the file API for this. It is definitely worth a try.
elusive
@Marcel It really depends on your target audience, this is not very widely compatible yet. Very interesting though.
deceze
A: 

Have you considered any other alternatives?

I have similar problem as you do, though i am using asp.net C#

this is my solution:

  1. of course, obvious user guidance of the image uploading control
  2. use server end image thumbnail facility, automatically resize the image into the right size that your system required.
  3. display result preview for user doing final review after upload.

it is ideal to check in client end first, however JS may causing compatibility issue. secondly, always check on server end, since client end is not always reliable.

D.J