开发者

Uploading image in MVC

I am using automatically created 开发者_如何学JAVA"Create" asp.net MVC view in which I have populated fields for underlying object.

Problem is that my object has property of type Image, and i Don't know how to populate it. I've tried to use file upload, but I don't know how to reference it from controller.

Thanx, V


Here's a sample Photo gallery in .Net MVC:

http://www.joshholmes.com/blog/2009/01/27/BuildingASimplePhotoGalleryInASPNETMVCFramework.aspx

Perhaps this will get you going down the right path. :-)


This is my code to get files from <input type="file">:

for (int i = 0; i < Request.Files.Count; ++i)
{
    var hpf = Request.Files[i];
    if (hpf.ContentLength > 0)
    {
        var file = new byte[hpf.ContentLength];
        hpf.InputStream.Read(file, 0, file.Length);
    }
}

Yeah, could use foreach.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜