开发者

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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜