It doesn’t feel like the.

Usman: I’m sure somebody’s packaged it up into json or something for you if you google

Wrona: Jeffreylevesque: let’s take a step back here: what problem are you trying to solve? Why do you want to find the mime type for something?

Yearby: I want to be able to validate the mimetype, so i can use jquery-validate

Larribeau: And the custom js logic i added into it

Fida: Jeffreylevesque: what’s jquery-validate? And what do you mean by “validate the mimetype”?

Zanghi: I did a simple test, and json mimetype is not supported –

Rueluas: Http://

Varady: Jeffreylevesque: are you trying to check if some file is of a certain type before sending it to the server?

Pedraza: Jeffreylevesque: anyway, it’s not something you should try doing. You can’t trust your client’s validation anyway

Usman: Jeffreylevesque: ok, so take the file extension, look up the mimetype in a mimetype database

Lozano: Jeffreylevesque: just check it on the server.

Usman: Yeah of course you can’t trust client validation. but file validation is something that is nice to duplicate on client side

Usman: No sense uploading a file you know will fail

Barscewski: Anyone here used jasney bootstrap before? looking to do off-canvas menu.

Usman: But absolutely step #1 is validate on the server side

Rule: Usman: should a .png-large image fail?

Usman: If the server will fail it, yes

Rebick: Even though it’s a proper png image, and just has the wrong extension

Usman: The point is just to make the JS save you uploading a file you know the server will reject

Oshiro: Well, sure, but should the server fail with that?

Usman: Not sure honestly. I don’t think looking for headers of every type of acceptable file is always practical

Baute: It’s doable for images. You’ll most likely want to load it and convert it to smaller thumbnails anyway

Scotting: And store smaller resolutions of the image

Usman: Maybe. and maybe you only support images. but that’s not always the case

Usman: I run an uploader that takes alllll kinds of stuff

Usman: So I just use file extension validation and I’m fine with that

Usman: I don’t mind telling a user to renmae a png to .png

Evenstad: Wait, so i should create another ajax request for the validation on the server, for the form?

Champlin: Or should i do validation on the file extension before form submission?

Wienberg: How can I Misuraca a button on page ready?

Usman: Jeffreylevesque: whatever you do, your *server* should be validating that the file is acceptable

Seman: Anyone have any critique / suggestions on how to clean up that if / else chain at the top of this funciton- ?

Usman: It would happen in the upload code itself

Usman: Jeffreylevesque: then, if you want, you can validate your client side using the exact same logic as your server. one approach may be to use a second ajax request yeah. one may just be to ship the validation logic from server to client

Usman: Or you could just ignore it entirely and only do server validation

Hubler: Usman: i think the file extension is good preliminary check. it can be spoofed, but so can the mimetype. ultimately, on the backend, my p****r wouldn’t work if it wasn’t formatted anyways

Helgerson: I don’t really like doing if a { x = a } else if b { x = b } etc.

Usman: But client validation only = no validation

Leval: And i can’t just do x = a b because the source value i’m also setting there.

Usman: Tejasmanohar: var x = a b;

Crumley: It doesn’t feel like the cleanest sloution though it very well may be