Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 26, 2012 03:07 AM by ignatandrei
Participant
1465 Points
1146 Posts
Nov 26, 2012 12:07 AM|LINK
Hi
does anyone have a good asp.net mvc tutorial on uploading an image and storing it a database,
also on a seperate question does piczard work with database images?
Contributor
2777 Points
1161 Posts
Nov 26, 2012 12:45 AM|LINK
[HttpGet] public ActionResult UploadImage() { return View(); }
[HttpPost] public ActionResult UploadImage( IEnumerable<HttpFileCollectionBase> files ) { var r = new List<ViewDataUploadFileResult>(); decimal id; id = Identity.LookupId( User.Identity.Name, dataProvider ); HttpFileCollectionBase fcb = Request.Files; if ( fcb.Count != 0 && fcb[0].ContentLength > 0 ) { Stream ifs = fcb[0].InputStream; byte[] b = new byte[fcb[0].ContentLength]; ifs.Read( b, 0, fcb[0].ContentLength ); MemoryStream ms = My_MSI.Net.Views.App_Code.Resize.ResizePicture( b, new Size( 100, 100 ), System.Drawing.Imaging.ImageFormat.Jpeg ); byte[] th = ms.GetBuffer(); My_MSI.Net.Models.Entities.Image.UploadPhoto( b, th, id, dataProvider ); r.Add( new ViewDataUploadFileResult( fcb[0].FileName, fcb[0].ContentLength ) ); } else { return View(); } ViewBag.ContentLength = fcb[0].ContentLength; return View( "UploadedFiles", r ); }
All-Star
134983 Points
21638 Posts
Moderator
MVP
Nov 26, 2012 03:07 AM|LINK
EnenDaveyBoy good asp.net mvc tutorial on uploading an image
http://www.hanselman.com/blog/ABackToBasicsCaseStudyImplementingHTTPFileUploadWithASPNETMVCIncludingTestsAndMocks.aspx
EnenDaveyBoy storing it a database,
any other EF tutorial
EnenDaveyBoy does piczard work with database images?
piczard?!
EnenDaveyBoy
Participant
1465 Points
1146 Posts
image upload and store in database mvc
Nov 26, 2012 12:07 AM|LINK
Hi
does anyone have a good asp.net mvc tutorial on uploading an image and storing it a database,
also on a seperate question does piczard work with database images?
eric2820
Contributor
2777 Points
1161 Posts
Re: image upload and store in database mvc
Nov 26, 2012 12:45 AM|LINK
[HttpGet]
public ActionResult UploadImage()
{
return View();
}
[HttpPost]
public ActionResult UploadImage( IEnumerable<HttpFileCollectionBase> files )
{
var r = new List<ViewDataUploadFileResult>();
decimal id;
id = Identity.LookupId( User.Identity.Name, dataProvider );
HttpFileCollectionBase fcb = Request.Files;
if ( fcb.Count != 0 && fcb[0].ContentLength > 0 )
{
Stream ifs = fcb[0].InputStream;
byte[] b = new byte[fcb[0].ContentLength];
ifs.Read( b, 0, fcb[0].ContentLength );
MemoryStream ms = My_MSI.Net.Views.App_Code.Resize.ResizePicture( b, new Size( 100, 100 ), System.Drawing.Imaging.ImageFormat.Jpeg );
byte[] th = ms.GetBuffer();
My_MSI.Net.Models.Entities.Image.UploadPhoto( b, th, id, dataProvider );
r.Add( new ViewDataUploadFileResult( fcb[0].FileName, fcb[0].ContentLength ) );
}
else
{
return View();
}
ViewBag.ContentLength = fcb[0].ContentLength;
return View( "UploadedFiles", r );
}
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
ignatandrei
All-Star
134983 Points
21638 Posts
Moderator
MVP
Re: image upload and store in database mvc
Nov 26, 2012 03:07 AM|LINK
http://www.hanselman.com/blog/ABackToBasicsCaseStudyImplementingHTTPFileUploadWithASPNETMVCIncludingTestsAndMocks.aspx
any other EF tutorial
piczard?!