asp.net-mvc-file-upload

How do you convert a HttpPostedFileBase to an Image?

匆匆过客 提交于 2019-12-17 17:26:28
问题 I am using ASP.NET MVC and I've an action that uploads the file. The file is being uploaded properly. But I want width and height of the image. I think I need to convert the HttpPostedFileBase to Image first and then proceed. How do I do that? And please let me know if there is another better way to get the width and height of the image. 回答1: I use Image.FromStream to as follows: Image.FromStream(httpPostedFileBase.InputStream, true, true) Note that the returned Image is IDisposable . You'll

File is empty and I don't understand why. Asp.net mvc FileResult

好久不见. 提交于 2019-12-10 23:00:00
问题 I am trying to use the built in asp.net file result to return a file that I am trying to make through a file stream. I am using Dday.ical to make my calendar for export MemoryStream export = new MemoryStream(); iCalendarSerializer serializer = new iCalendarSerializer(iCal); serializer.Serialize(export,System.Text.Encoding.Default); return export; Here is my actionResult public ActionResult ExportCalendar() { string userName = User.Identity.Name; Guid userId = membershipS.GetUsersId(userName);

Uploading Multiple Files - MVC..is there a total file size limit?

╄→гoц情女王★ 提交于 2019-12-09 01:14:50
问题 I have a form from which users can add a property listing. Apart from the data that the user has to enter, the user can also upload a number of images. I'm using the HTML5 multiple attribute to allow users to upload more than one file at once. For some reason the HttpPost Add method I have always fires when I upload one image. However, when I try to upload multiple images the method does not fire. Up till now I'm not getting any errors so I'm not sure what is wrong with my implementation.

How do you convert a HttpPostedFileBase to an Image?

岁酱吖の 提交于 2019-11-28 03:15:35
I am using ASP.NET MVC and I've an action that uploads the file. The file is being uploaded properly. But I want width and height of the image. I think I need to convert the HttpPostedFileBase to Image first and then proceed. How do I do that? And please let me know if there is another better way to get the width and height of the image. I use Image.FromStream to as follows: Image.FromStream(httpPostedFileBase.InputStream, true, true) Note that the returned Image is IDisposable . You'll need a reference to System.Drawing.dll for this to work, and Image is in the System.Drawing namespace.