FAQ Database Discussion Community


Avoid EF update the null image to database in .Net MVC

asp.net-mvc,entity-framework,null,edit,httppostedfilebase
In my SachController, there is an Edit method like below. In the view, there are several textbox and one file-input for upload image object. Sometime, user doesn't want to change the image and they just don't select a new image. And the image (HttpPostedFileBase) is null. How can I avoid...

Why does HttpPostedFileBase error out on large files before server side validation gets called?

javascript,c#,asp.net-mvc,httppostedfilebase
If I disable client side validation <add key="ClientValidationEnabled" value="false" /> <add key="UnobtrusiveJavaScriptEnabled" value="false" /> and try to upload a file that's around 11 MB which sets the file to a HttpPostedFileBase memeber [ValidateFile] public HttpPostedFileBase StudentImageFileBase { get; set; } I can't even get my custom validation code to get...

unable to convert uploaded image to byte array

c#,bytearray,binaryreader,httppostedfilebase
I am trying convert an uploaded image to a byte array so that I can store it in a database table. The code below is used to perform the conversion from an image into a byte array: public byte[] ConvertToBytes(HttpPostedFileBase image) { BinaryReader reader = new BinaryReader(image.InputStream); var imageBytes =...

MVC 6 HttpPostedFileBase?

asp.net-mvc-6,httppostedfilebase
I am attempting to upload an image using MVC 6; however, I am not able to find the class HttpPostedFileBase. I have checked the GitHub and did not have any luck. Does anyone know the correct way to upload a file in MVC6? Truly appreciated, Steven M....