views:

28

answers:

1

i want to check that user upload file is image or not.

how i can check the type of file is image or not. are any way exist to do this.

+2  A: 

You need to use useful jQuery validation plugin which does support the files you want to allow for upload other than other nice options.

You can use the accept property of the validation plugin to allow file types you want, here is an example:

$("#form_id").validate({
  rules: {
    field: {
      required: true,
      accept: "gif|jpeg"
    }
  }
});
Sarfraz
i have some other field in the form then how i can check.
steven spielberg
@steven: You can use the `element()` method: http://docs.jquery.com/Plugins/Validation/Validator/element#element. See the docs for more info.
Sarfraz