UploadedFile Object
Overview
This object resides in the UploadManager.Files collection and represents an uploaded file.
Member List
Properties
Sets and returns this file's system attributes. Can be a combination of file attribute values defined in the AspUpload type library:
FILE_ATTR_READONLY = &H1
Usage:
FILE_ATTR_HIDDEN = &H2
FILE_ATTR_SYSTEM = &H4
FILE_ATTR_DIRECTORY = &H10
FILE_ATTR_ARCHIVE = &H20
FILE_ATTR_NORMAL = &H80
FILE_ATTR_TEMPORARY = &H100
FILE_ATTR_COMPRESSED = &H800
<!--METADATA TYPE="TypeLib" UUID="{B4E1B2DE-151B-11D2-926A-006008123235}"-->
Response.Write File.Attributes
File.Attributes = File.Attributes + FILE_ATTR_READONLYRelevant Chapters: 6
Returns the binary image of the file as a Variant-packed safe array of bytes. Useful for saving files in the database using ADO.
Usage:rs.AddNew
rs("image_blob).Value = File.Binary
rs.UpdateRelevant Chapters: 4
Returns the uploaded file's Content-Type header value, such as "text/plain" or "application/octet-binary".
Usage:Response.Write File.ContentType
Returns the file's Creation timestamp. This property is not defined if this is a memory file.
Usage:Response.Write File.CreationTime
Returns the file extension.
Usage:Response.Write File.ExtRelevant Chapters: 3
Returns the saved file's name. It may be different from the original file name if unique file generation (the property Upload.OverwriteFiles) is in effect.
Usage:Response.Write File.FileNameRelevant Chapters: 2
Returns the saved file's folder. If this is a memory file, the folder will be the same as the original folder.
Usage:Response.Write File.Folder
Returns the pixel height of an image, or 0 if the file is not an image. Formats supported are BMP, JPG, GIF, PNG and WEBP.
Usage:Response.Write File.ImageHeightRelevant Chapters: 7
Returns the image type. Possible return values are "BMP", "GIF", "JPG", "PNG", "WEBP", and "TIF" for BMP, GIF, JPEG, PNG, WEBP and TIFF images, respectively, and "UNKNOWN" if the file is not an image or of an unknown image type.
Usage:Response.Write File.ImageTypeRelevant Chapters: 7
Returns the pixel width of an image, or 0 if the file is not an image. Formats supported are BMP, JPG, GIF, PNG and WEBP.
Usage:Response.Write File.ImageWidthRelevant Chapters: 7
Returns the file's Last Access timestamp. This property is not defined if this is a memory file.
Usage:Response.Write File.LastAccessTimeRelevant Chapters: N/A
Returns the file's Last Write timestamp. This property is not defined if this is a memory file, unless the file is uploaded with XUpload or JUpload, and the PreserveFileTime feature is enabled.
Usage:Response.Write File.LastWriteTime
Returns the file's MD5 one-way hash value in the Hex format.
Usage:Response.Write File.MD5HashRelevant Chapters: 4
Returns the value of the NAME attribute of this file's <INPUT TYPE=FILE> tag. This property cannot be used to retrieve the file name, use FileName instead.
Usage:Response.Write File.NameRelevant Chapters: 2
Returns the original name of the uploaded file.
Usage:Response.Write File.OriginalFileName
Returns the original folder path of the uploaded file.
Usage:Response.Write File.OriginalFolder
Returns the original full path of the uploaded file.
Usage:Response.Write File.OriginalPath
Returns the original size of the uploaded file. This value may be different from the current size if file truncation is enabled via the SetMaxSize method.
Usage:Response.Write File.OriginalSize
Returns the full path of the uploaded file on the server.
Usage:Response.Write File.PathRelevant Chapters: 2
Enables translation of characters in POSTed text items and file names from the specified code page to Unicode. If the data is posted in the UTF-8 format, set this property to 65001. Other valid values include, but are not limited to, 1251 (Cyrillic), 1255 (Hebrew), 1256 (Arabic), etc.
Usage:Upload.CodePage = 65001Relevant Chapters: 8
Methods
Adds an allowance access control entity (ACE) corresponding to the specified NT Account to this file's Access Control List (ACL). Flags must be a valid combination of Access Type values defined in the file AspUpload.inc such as GENERIC_ALL. Other valid flag combinations include:
Read (RX):GENERIC_READ + FILE_GENERIC_EXECUTE
Change(RWXD): GENERIC_READ + GENERIC_WRITE + FILE_GENERIC_EXECUTE + DELETE
Full Control (All): GENERIC_ALL
Usage:
File.AllowAccess "jsmith", GENERIC_ALLRelevant Chapters: 6
Copies this file to a location specified by Path which must be a fully qualified path.
If Overwrite is set to True or omitted, overwrites an existing file. If Overwrite is set to False and a file at Path already exists, the method will fail.Usage:
File.Copy "c:\newpath\" & File.FileNameRelevant Chapters: 3
Same as Copy, but expects a virtual rather than physical path. If the system admin disables the Copy method, users are forced to use CopyVirtual which confines them to their own home directory and subdirectories.
Usage:
File.CopyVirtual "/uploads/" & File.FileNameRelevant Chapters: 10
Deletes the file.
Usage:
File.DeleteRelevant Chapters: 3
Adds a denial access control entity (ACE) corresponding to the specified NT Account to this file's Access Control List (ACL). Flags must be set to GENERIC_READ.
Usage:
File.DenyAccess "jsmith", GENERIC_ALLRelevant Chapters: 6
Creates an empty file. Obsolete. Supported only for backwards compatibility. Use FileName instead
Usage:
Response.Write File.ExtractFileName
Obsolete. Supported only for backwards compatibility. Use Folder instead.
Usage:
Response.Write File.ExtractFolderName
Copies this file to a location specified by Path which must be a fully qualified path. If a file at Path already exists, the method will fail.
Usage:
File.Move "c:\newpath\" & File.FileNameRelevant Chapters: 3
Same as Move, but expects a virtual rather than physical path.
Usage:
File.MoveVirtual "/uploads/" & File.FileNameRelevant Chapters: 10
Removes the corresponding allowance ACE from this file's ACL.
Usage:
File.RevokeAllowance "jsmith"Relevant Chapters: 6
Removes the corresponding denial ACE from this file's ACL.
Usage:
File.RevokeDenial "jsmith"Relevant Chapters: 6
Saves the file under the name specified by Path. If UploadManager.OverwriteFiles is set to False and a file specified by Path already exists, this method will generate a unique file name by appending a numeric suffix such as (1), (2), etc. to the file name.
This method is especially useful when uploading to memory, as this is the only way to save a memory file to disk.
Side effect: if the method succeeds, the UploadedFile.Path property will be changed to Path (or a unique file name derived from it).
Usage:
File.SaveAs "c:\path\" & File.FileNameRelevant Chapters: 4
Same as SaveAs, but expects a virtual rather than physical path. If the system admin disables SaveAs, users will be forced to use SaveAsVirtual which confines them to their home directory and subdirectories.
Usage:
File.SaveAsVirtual "/path/" & File.FileNameRelevant Chapters: 10
Sets the NTFS owner of this file to the Windows Account specified.
Usage:
File.SetOwner "jsmith"Relevant Chapters: 6
Saves the file specified to the database as a BLOB using ODBC.
Connect is an ODBC connection string which may use a system DSN, or be DSNless, for example:
"DSN=mydb;UID=sa;PWD=xxxxx"
or
"Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\path\db.mdb"
However Connect cannot be an ADO-style connection string, i.e. it cannot reference an OLD DB provider, as this method is based on ODBC.
SQL is an SQL INSERT or UPDATE statement which uses the sign ? as a placeholder for the file being saved in the database, for example:
"INSERT INTO mytable(image_blob, path) values(?, 'c:\path\file.ext')"
or
"UPDATE mytable SET imageblob = ? WHERE id = 15"
The MSAccessHeaders parameter may only be used with MS Access databases. If set to True, AspUpload will attempt to save the file not as a Blob but as an OLE Object so that the document can be invoked directly from MS Access by double-clicking on the table field. This feature will only work with file types for which OLE document servers exist, such as MS Word documents (*.doc), Excel workbooks (*.xls), bitmaps (*.bmp), etc. For other types of files (such as *.gif) the MSAccessHeaders parameter will be ignored and assumed False. Note that you will not be able to download a document saved as an OLE Object directly to the browser.
Usage:
File.ToDatabase "DSN=mydb;UID=sa;PWD=xxxx;", "insert into myimages(image_blob) values(?)"Relevant Chapters: 4