Which is best way to upload single file with asp.net mvc3 razor and validate with jquery.
I only need to user upload jpg, png less then 5 mb.
Thanks
Which is best way to upload single file with asp.net mvc3 razor and validate with jquery.
I only need to user upload jpg, png less then 5 mb.
Thanks
Aside jQuery validation (very nice Acid's answer) You should also do server validation. Here's some simple example:
VIEW:
CONTROLLER:
ImageUtility helper class:
You could also tinker with response format, different file renaming or adding functionality for multiple file handling etc.
You will need to validate with javascript, here is a sample
this says the file must be no greater than 256K and allows only gif, jpg, jpeg, tif, png and pdf. Just change 256000 to 5000000 and your specific file type
I'm using this in MVC 3 in a razor view with the Telerik upload control. You can use with a standard upload input as well, just fire this event on selection or before committing
This is just to specify file types to be accepted: MSvisualstudio2010.
In your View(.cshtml):
Just specify the formats you need.