Wondering whether there is there a nicer way to detect whether a file was actually uploaded than this?
if (Request.Files["ProfileImage"].InputStream.Length > 0)
{
newCat.ProfileImage = SaveProfileImage();
}
In my web page there is a file control with name “ProfileImage”
<input type="file" name="ProfileImage" />
You can just use the
HttpPostedFile.ContentLength, but that’s pretty much the same thing.If you were using the
<asp:FileUpload />control, then you could access theHasFileproperty, but you’re not 🙂