PDA

View Full Version : how to make upload filter


bmwmpower
03-19-2003, 10:24 AM
i need help in how i can make upload filter

i mean the user can upload only images so any one can help me and tell me the code

raf
03-19-2003, 01:16 PM
cant you just check the file-extension ?

Right(string,5) should be .jpeg
Right(string,4) should be .bmp or .gif or .tif ...

of coarse, then you still don't know if it's an image file, course it could be a renamed file ...

bmwmpower
03-22-2003, 08:01 AM
ok can u tell me the code

dominicall
03-22-2003, 07:06 PM
Code is...
Dim imagefilename
imagefilename = Request.Form("frmImageFileName")
If Right(imagefilename,4) <> ".jpg" AND Right(imagefilename,4) <> ".gif" Then
Response.Redirect "formpage.asp?error=notimage"
Else
....do what you want with the image
End IfThen all you need to do on the form page is put a check for the error quesrystring containing "notimage" - only if it does, show an error message....

Some of the Upload/Image manipulation server components will specifically check the image type which is more reliable since using the method I've described above will only check the file name - not the actual data type so someone could rename a malicious script file and upload that file. But it's a nice, quick and dirty approach....

dominicall :D

Mhtml
03-23-2003, 04:42 AM
Yeah, I think ASP Upload has the feature dominicall was talking about.
http://www.aspupload.com

dominicall
03-23-2003, 06:33 AM
ASPUpload (from Persits Software - http://www.persits.com) is the one that I tend to use most often...

If you're working with images they also have a component call ASPJpeg, which is great for image manipulation on the server.

dominicall

Morgoth
03-23-2003, 07:48 AM
Persist, great programs...
I have bought, AspUpload and AspJpeg... Very good...