jQuery - INPUT type=File , Image FileType Validation options?

后端 未结 6 1863
误落风尘
误落风尘 2020-12-29 09:08

I have the following:


On the server I check to make sure it\

6条回答
  •  Happy的楠姐
    2020-12-29 09:22

    There may be browsers that allow you to create a of the given path, by that you could check if it's a real image or not(if not the onerror-event should fire on the image and it will have a width/height of 0).

    But as this only works in some browsers and is an security-risk(in my mind) I would'nt suggest to do this, so my answer is: you can't validate there anything.

    Checking the file-extensions like suggested by Alex may be an option, but the file-extension does not guarantee if it's a image. However, as a simple pre-check(not validation) it could be useful.

提交回复
热议问题