I am using a File Upload control on my Contour form and was just wondering if I can validate any file that is picked.
When I use other field types, such as the Textbox control, I can see the option to apply regex. However, there is no option to add this on the File Upload control.
I was thinking of incorporating jQuery validate; however, all that would be required to get around this is to disable JavaScript.
Using the razor macro you can hook into the form validation... it's even easier when using code first check out the examples here http://www.nibble.be/?p=205
As I'm using Contour 2, I can't use the razor macro to hook into form validation. Therefore, I found this 'addon' to allow me to achieve what I wanted.
Otherwise, each time a file was uploaded with the same name, it would be overwritten in the directory. The re-worked line creates a new folder with the name of Guid.NewGuid() and drops the uploaded file into that specific folder.
File Upload Control - Contour 2
Hi,
I am using a File Upload control on my Contour form and was just wondering if I can validate any file that is picked.
When I use other field types, such as the Textbox control, I can see the option to apply regex. However, there is no option to add this on the File Upload control.
I was thinking of incorporating jQuery validate; however, all that would be required to get around this is to disable JavaScript.
Can anyone help?
Many thanks
Rick
Comment author was deleted
Using the razor macro you can hook into the form validation... it's even easier when using code first check out the examples here http://www.nibble.be/?p=205
Tim, thanks for the lightning quick reply!
As I'm using Contour 2, I can't use the razor macro to hook into form validation. Therefore, I found this 'addon' to allow me to achieve what I wanted.
http://our.umbraco.org/projects/backoffice-extensions/cogworks-cogfilteredupload
However, a word of warning for others when using this 'addon'... I had to alter this line in the class:
string dir = Configuration.Path + "/files/" + this.AssociatedField.Form.ToString() + "/";
to this:
string dir = Configuration.Path + "/files/" + this.AssociatedField.Form.ToString() + "/" + Guid.NewGuid().ToString() + "/";
Otherwise, each time a file was uploaded with the same name, it would be overwritten in the directory. The re-worked line creates a new folder with the name of Guid.NewGuid() and drops the uploaded file into that specific folder.
Hope this helps someone out there!
Rick
is working on a reply...