There are times when you may need to restrict the type of files saved on the Web
server. You can do so by using FileUp's ContentType
property and a Select
condition to save
only files that are a certain type.
Once your file is uploaded, you would include the following after creating an instance of FileUp:
Server-Side Code |
---|
<%
|
We get the media content-type of the file uploaded by using the ContentType
property. In this example, we accept only .gif and .jpeg files. So we are looking
for either "image/pjpeg" or "image/gif" as the media content-type.
A Case condition statement is used to save the correct file and send a successful
response. Notice that the property ShortFileName
is used to supply the name of the file that was saved.
If the file type is incorrect, the file will be deleted and an error response will
sent.
ContentType
property, and use a Select Case
condition statement.
ShortFileName
and parsing for the extension.