Detecting whether file was uploaded
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" 开发者_C百科/>
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 :)
精彩评论