views:

155

answers:

2

I am using automatically created "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

+1  A: 

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

klabranche
A: 

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.

LukLed