|
Well, first of all you need an uploader component. If possible, use an ActiveX DLL component for the uploader. If not possible, there are dozens of "pure ASP" uploaders out there, some better than others.
Re restricting to jpg only: You *can* check the file name of the uploaded file to be sure it ends in ".jpg" or ".jpeg", but of course there's nothing to prevent somebody from renaming a ".exe" to ".jpg" and slipping it past you.
The best way to ensure you are getting an image is again to use an ActiveX DLL component for images. You load the uploaded file into the imaging component and make a minor change to it (e.g., resize it by one pixel? or add a dummy blank pixel or two say in the bottom right corner) and then re-save it back out as a JPG image. If that works, you know you have an image. If the imaging component complains about an invalid image format, you know you've been spoofed.
Most hosting services supply these components as part of an ASP hosting package. For example, GoDaddy does so for even their $5 a month plan. If you are self-hosting, you can purchase and install such components, but the purchase price will probably be a couple of hundred dollars or more, so a cheap hosting plan may be more economical.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
|