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
ContentTypeproperty 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:
We get the media content-type of the file uploaded by using the
ContentTypeproperty. 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
ShortFileNameis 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
ContentTypeproperty, and use a
Select Case condition statement.
ShortFileNameand parsing for the extension.