Hi folks.
I want to allow members of a member site to upload images to a specific folder, the location of which is hard-coded.
I've got that part sorted OK, but it's very important that I be able to restrict the file types to certain image types (GIF JPG/JPEG PNG BMP) and that the file uploaded really be an image file, and not something potentially dangerous like a renamed .exe.
Now I realize I could take the long route and parse the filename, extract the extension and filter on that, but it's my understanding that, for various reasons, this is an insecure solution, and that it's much more preferable to get the required information from the mime type.
And that's where I'm stuck. I'm just starting out with VB.NET and so not capable of coming up with this myself.
What I really need is a generic ready-made mime detector class, which I have searched widely for. I did come up with one, but the JavaScript download links don't work (yes, I joined and logged in) and I haven't yet had a response from them about those links. The URL:
Detect file type or mime type based on content
A pity, because to my inexperienced eye it seems to be just what I need.
As .NET apparently doesn't provide any simple way to do mime detection, I would think this to be something a lot of people could use.
Any hints, pointers, suggestions most welcome.
I want to allow members of a member site to upload images to a specific folder, the location of which is hard-coded.
I've got that part sorted OK, but it's very important that I be able to restrict the file types to certain image types (GIF JPG/JPEG PNG BMP) and that the file uploaded really be an image file, and not something potentially dangerous like a renamed .exe.
Now I realize I could take the long route and parse the filename, extract the extension and filter on that, but it's my understanding that, for various reasons, this is an insecure solution, and that it's much more preferable to get the required information from the mime type.
And that's where I'm stuck. I'm just starting out with VB.NET and so not capable of coming up with this myself.
What I really need is a generic ready-made mime detector class, which I have searched widely for. I did come up with one, but the JavaScript download links don't work (yes, I joined and logged in) and I haven't yet had a response from them about those links. The URL:
Detect file type or mime type based on content
A pity, because to my inexperienced eye it seems to be just what I need.
As .NET apparently doesn't provide any simple way to do mime detection, I would think this to be something a lot of people could use.
Any hints, pointers, suggestions most welcome.