I am trying to upload a file with ASP.NET MVC.
The following code work perfectly fine:
// Read in the image data.
byte[] binaryData = null;
HttpPostedFil
For the past week i have been building an upload/file manager system for my MVC project and my original attempt was to post additional post data with the multipart files values. this proved too difficult for my time constraints. my approach now is to create the "respective record" to which files/images may be 'attached' (as it is in my case), -then- upload ('attach') the files/images after the record is present.
for example: 1) create event record, 2) attach images with upload control
My action that receives the multipart post uses the concepts from Hanselman's post.
I cant say i've tried the built-in complex-type binding for files (HttpPostedFileBase) but i'd suggest that it would be more complex than my present solution given that from reading the post Hanselman wrote above - i've learned that the files collection returned in the Request
is only a loosely typed collection.
I'd suggest sticking to your original code and trying to make that more safe for your purposes.