This contains the name of the uploaded file translated into a
format that can be used to save the file. The SafeFileName includes
any file name extension but does not include any directory
information. In general you should only use the SafeFileName for
saving the file when the original name is essential to the upload.
In other cases you should assign a new name to your file to allow
you to maintain control over the names of files saved on your
Note that the fact that the file name is safe for saving does
not mean that it is safe to use in a URL. For instance it may
contain spaces or Unicode characters. If you need a URL safe name
you should use the FileName property.
You should not use the SafeFileName property in virtual
pathnames. Active Server Pages cannot resolve virtual paths
containing Unicode characters into physical pathnames. If you wish
to write a Unicode file into a virtual directory you should use
code of the following form.
theForm.AbsolutePath = True
thePath = Server.MapPath("mydirectory\") &
The translation is done for two purposes. Firstly some platforms
allow characters such as question marks and slashes to be used in
the name of files. When these types of files are uploaded the file
cannot be saved using these characters and they must be removed or
translated into some other form.
If files containing illegal characters are uploaded from
Macintosh browsers the names will be translated into the standard
Services for Macintosh (SFM) Unicode format so that they can be
saved intact. To a Windows user the file may appear to contain
unusual characters but to a Macintosh user the name will appear as
it was when uploaded.
In other cases when uploaded file names contain illegal
characters these are deleted so that the file name can be used as
part of a save name.