0

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.

1 Answer 1

1

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"
    }
  }
});
Sign up to request clarification or add additional context in comments.

2 Comments

i have some other field in the form then how i can check.
@steven: You can use the element() method: docs.jquery.com/Plugins/Validation/Validator/element#element. See the docs for more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.