IsEmpty Property

Object: SoftArtisans.FileUp
Syntax: IsEmpty
Type: Boolean
Read/Write: Read Only
Description:

This property displays whether the user specified a valid file to upload.

When a user is filling out a form containing a file (<input type="file" />), there are three possibilities:

  1. The user specifies a valid filename on the local PC.
  2. The user leaves the filename field blank, decides not to transmit a file, but presses the submit button anyway.
  3. The user specifies a filename that is either invalid or indicates a file that is unreadable.

In the second and third cases, the browser does not report an error. The browser simply proceeds with the upload but leaves the file contents of the upload empty.

Your recourse is to let the user perform the upload and test the IsEmpty property.

If the property is True, the user did not transmit a valid file.

If the property is False, the user did transmit a valid file.

If there is more than one file being uploaded in a single page, only the first one is displayed.

To examine the IsEmpty property of multiple files in a single upload, there is an equivalent property for each file object, i.e., fileUpload.Form("File1").IsEmpty. See SAFile.IsEmpty.

Examples:
ASP <% If fileUpload.IsEmpty Then %>
The file that you uploaded was empty. Most likely, you did not
specify a valid filename to your browser or you left the
filename field blank. Please try again.
<% Else >
'--- Process upload
< End If %>
C# if (fileUpload.IsEmpty)
{
results.Append("The file that you uploaded was empty. Most " +
"likely you did not specify a valid filename to your " +
"browser or you left the filename field blank. " +
"Please try again."); }
else
{
//--- Process upload
}
VB.NET If (fileUpload.IsEmpty) Then

results.Append("The file that you uploaded was empty. Most " + _
"likely you did not specify a valid filename to your browser " + _
"browser or you left the filename field blank. " + _
"Please try again.");
Else

'--- Process upload

End If

Copyright © 2010 SoftArtisans, Inc. All rights reserved.