Documentation > CMS Template API Library > UploadedFiles > HasKey(String)
HasKey
Was the given field submitted on the last post.
public System.Boolean HasKey(String)
Parameters
| Name | Description | Type |
|---|---|---|
| key | The key to check for. | System.String |
Code Example
C#
Sample:
if(context.InputForm.UploadedFiles.HasKey("main_image"))
{
// Usually called from post_input.aspx
Img img = context.UploadedFiles["my_photo"].Img;
if (!img.HasError)
{
// It's likely lasso params from the input would be used for these dimensions
ImgResult res = img.CropImage(300, 300, 0, 0, 500, 500);
if (res.HasError)
{
context.Error = "Upload Error cropping image on " + value + " error: " + res.ErrorMessage;
}
}
else
{
context.Error = "Image Error Loading on " + context.UploadedFiles["my_photo"].Path + " error: " + img.ErrorMessage;
}
}