Reputation: 8422
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" />
Upvotes: 3
Views: 171
Reputation: 11530
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 the HasFile
property, but you're not :)
Upvotes: 2