AspUpload is capable of determining the type and pixel size
of uploaded images. The formats currently supported are GIF, JPEG, BMP and PNG.
The type and size information is returned via the properties
File.ImageType, File.ImageWidth, and File.ImageHeight.
The property File.ImageType
returns the strings "GIF", "JPG", "BMP", "PNG"
(for GIF JPEG BMP and PNG images, respectively), or "UNKNOWN"
if the file is not an image or of an unknown image type.
The properties File.ImageWidth and File.ImageHeight
return the image width and height in pixels, or 0
if the file is not an image.
The code samples size.asp and size_upload.asp
demonstrate the usage of these properties.
|
<!--#include file="AspUpload.inc"-->
<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persits.Upload")
' Capture and save uploaded image
Upload.Save "c:\upload"
For Each File in Upload.Files
If File.ImageType = "UNKNOWN" Then
Response.Write "This is not an image."
Response.End
End If
Response.Write File.Path & "<BR>"
Response.Write "Type: " & File.ImageType & "<BR>"
Response.Write "Size: " & File.ImageWidth & " x " & File.ImageHeight & " pixels"
Next
%>
</BODY>
</HTML>
|
Click the link below to run this code sample:
http://localhost/aspupload/07_images/size.asp