Steven Spielberg
Steven Spielberg

Reputation:

how to check in jquery javascript that user upload file is image or not

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.

Upvotes: 0

Views: 847

Answers (1)

Sarfraz
Sarfraz

Reputation: 382696

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"
    }
  }
});

Upvotes: 1

Related Questions