httppostedfilebase

ASP.NET MVC posted file model binding when parameter is Model

Is there any way to get posted files (<input type="file" />) to take part in model binding in ASP.NET MVC without manually looking at the request context in a custom model binder, and without creating a separate action method which only takes a posted file as input? I would have thought that this would work: class MyModel { public Ht...

Why doesn't HttpPostedFile perform as advertised and buffer downloads to disk rather than memory?

I am uploading large files to an ASP.NET server using a standard HTML <input> control posting multipart-form data. This is an ASP.NET MVC application. According to MSDN, the HttpPostedFile class buffers to disk out of the box: "Files are uploaded in MIME multipart/form-data format. By default, all requests, including form fiel...

How do you convert a HttpPostedFileBase to an Image?

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

ASP.Net MVC image upload failing in Google Chrome.

I have an image upload form <% using (Html.BeginForm("PictureValidateAndSave", "UserGallery", new {}, FormMethod.Post, new { enctype = "multipart/form-data"})) { %> <table> <tr> <td> Album Name: </td> <td> <%= Html.DropDownList("albumList") %></td> </tr> <tr> <td> File Loc...

Model binding HttpPostedFileBase and then storing the file to datastore

ASP.NET MVC seems to correctly automatically bind between HTML form's file input field and HttpPostedFileBase. On the other hand it cannot bind from file input field to byte array..I tried and it issues exception - something about not being able to convert to Base64. I had only the byte array property on my Model classes previously becau...

When I try to upload a file in ASP.NET MVC, it shows as null

For some reason the paramater OriginalLocation is always null in the following code. What am I doing wrong? Controller: [HttpPost] public ActionResult File(HttpPostedFileBase OriginalLocation, FileModel model) { byte[] binaryData = null; if (OriginalLocation != null && OriginalLocation.ContentLength > 0) { bi...

ASP.NET MVC File Uploading

HI there, My model (partial) public class Document : HttpPostedFileBase { public string DocumentTitle { get; set; } public string DocumentType { get; set; } My action [AcceptVerbs(HttpVerbs.Post)] public ActionResult AddDocumentToVault(Document model) { foreach (string upload in Request.Fi...

ASP.NET MVC passing Model *together* with files back to controller

Ok, I've been going at this for several hours and I simply cannot find the solution. I want to get some data from my user. So first, I use a controller to create a view which receives a Model: public ViewResult CreateArticle() { Article newArticle = new Article(); ImagesUploadModel dataFromUser = new ImagesUploadModel(newArticl...