Required upload file

Required upload file

dynasoftdynasoft Posts: 310Questions: 51Answers: 3

Link to test case:
Debugger code (
Error messages shown:
Description of problem: Hi, how can I make uploadinga file a requirement. The following does not trigger the Required validator:

                editor.Field(new Field("FTR.UserFileID")
                    .Validator(Validation.Required(new ValidationOpts
                        Message = lblo.lblEnsureFileUploaded
                    .Upload(new Upload(SetGetUserPriceListsDir + @"\__ID____EXTN__")
                        .Db("UserFiles", "id", new Dictionary<string, object>
                            {"WebPath", Upload.DbType.WebPath},
                            {"SystemPath", Upload.DbType.SystemPath},
                            {"FileName", Upload.DbType.FileName},
                            {"FileSize", Upload.DbType.FileSize}

Also what is the syntax for including functions in the validtors for .net. The following on is for php:

Upload::inst( ... )
->validator( function ( $file ) {
if ( $file['size'] >= 500000 ) {
return "Files must be smaller than 500K";
return null;
} )

Many thanks.


  • allanallan Posts: 51,750Questions: 1Answers: 7,832 Site admin

    The .NET manual page for validation shows the .NET upload syntax. The download package for .NET also includes an upload example matching the PHP one.

    Regarding the required validator, that looks like the correct way of doing it. It should give you an error when you attempt to submit the form. What happens when you do?


  • dynasoftdynasoft Posts: 310Questions: 51Answers: 3

    Many thanks. Not sure what happened but the required validator wasn't triggering before but got it to work today. Thanks again.

Sign In or Register to comment.