I have an upload that stores images to a SQL 2008 from an ASP.NET MVC 3 application like this:
...
foreach (var httpFile in files)
{
TestProj.Models.File file = new TestProj.Models.File();
using (BinaryReader reader = new BinaryReader(httpFile.InputStream))
{
file.FileContent = reader.ReadBytes(httpFile.ContentLength);
}
file.FileName = httpFile.FileName;
file.FileExtension = (httpFile.FileName.Contains(".")) ?
httpFile.FileName.Substring(httpFile.FileName.LastIndexOf('.') +1) : "";
file.FileSize = file.FileContent.Length;
file.ContentType = httpFile.ContentType;
_fileRepository.AddFile(file);
...
I also have 2 columns “Width” and “Height” were I would like to insert the size of the image uploaded.
Is there some easy way of reading the width and height using the reader?
Thanks in advance
/Lasse
Use Image.Width and Image.Height property.