Documentation > CMS Template API Library > UploadedFile > Matches(String)

Matches

See if the particular Uploaded File has the key we are looking for. Usually used in the upload.aspx

public System.Boolean Matches(String)


Returns

true if the key matches

Parameters

NameDescriptionType
uploadKey The name of the upload field. Used to see if this uploaded file instance is a particular uploaded file. System.String

Code Example

C#

Sample:

             
               // Usually called from upload.aspx
               UploadedFile imageUpload = context.UploadedFile;
                    
              // my_photo_thumbnail was used in input.aspx because we want to display the thumbnail when we edit, not the possibly large original
              if (imageUpload.Matches("my_photo_thumbnail"))
              {
            
                asset.SaveUploadedFile("my_photo", imageUpload); // it gets overwritten later when it is resized to 300x300
                ImgResult res = asset.CreateThumbnail(imageUpload, "my_photo_thumbnail", 300, 300);
                if (res.HasError)
                {
                   context.Error = "Upload Error creating thumbnail on " + value + " error: " + res.ErrorMessage;           
                 }  
              }
              else
              {
                context.Error = "Upload Error Loading on " + value + " error: " + img.ErrorMessage;           
              }
             
             
             

Connect with Crownpeak