Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Richy 8 posts 78 karma points
    Jul 06, 2016 @ 12:11
    Richy
    0

    Custom Field Type Contour - Error loading MacroEngine script (file: MvcRenderContourForm.cshtml)

    Hi,

    I'm trying to create a custom field type and extend on the FileUpload control. However I'm having an issue where when I try to browse to the form containing the custom field type I get the error.....

    Error loading MacroEngine script (file: MvcRenderContourForm.cshtml)

    As far as I can tell I've created the custom field with the bare minimum(no functionality yet) but I'm still getting the error. I also get the error if I click the preview button in contour. The code is shown below, as I say I've tried to strip it back to the bare minimum so why is it failing?

    Thanks

    Richy

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Web;
    using System.Web.UI.WebControls;
    using Umbraco.Forms.Core;
    using Umbraco.Forms.Core.Controls;
    
    namespace FilteredUpload
    {
        public class FilteredUpload : FieldType
        {
            public FilteredUpload()
            {
                Id = new Guid("0B690268-072C-5CDA-4BC5-27B9873AC2D0");
                Name = "Filtered Upload";
                Description = "Filtered File Upload";
                Icon = "upload.png";
                DataType = FieldDataType.LongString;
            }
    
            public override string RenderPreview()
            {
                return String.Format("<input type=\"file\" />");
            }
    
            public override string RenderPreviewWithPrevalues(List<object> prevalues)
            {
                return RenderPreview();
            }
        }
    }
    
  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Jul 08, 2016 @ 10:25
    Warren Buckley
    0

    Hello Richy,
    I would look in the UmbracoLogFiles to see what the underlying exception error message is.

    Once you find this can you please post here so I can try to help you with your problem.

    At first glance of your FieldType extension it seems OK to me.

    If you are trying to create a file upload that only accepts certain filetypes this will soon be coming to the core of Umbraco Forms product but in the meantime the awesome Umbraco community has stepped forward & built Umbraco Forms on Perplex Steroids which adds this along with other items.

    https://our.umbraco.org/projects/backoffice-extensions/umbraco-forms-on-perplex-steroids/

    Thanks,
    Warren

  • Richy 8 posts 78 karma points
    Jul 11, 2016 @ 17:00
    Richy
    0

    Thanks, should have looked in the log. I didn't have a cshtml file for the new fieldtype in the views folder.

    I spotted the Umbraco Forms on perplex steroids but I'm using Umbraco 6.2.4 and contour 3.0.24 so am I right in thinking that it isn't an option for me?

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Jul 12, 2016 @ 07:32
    Warren Buckley
    0

    Glad you found your problem.

    Yes you are right Umbraco Forms on Perplex Steroids is for Umbraco Forms only and not Umbraco Contour. However you may be able to look at some of their custom FieldTypes to help build your own.

    Thanks,
    Warren

  • Richy 8 posts 78 karma points
    Jul 12, 2016 @ 14:11
    Richy
    0

    What I'm trying to achieve is to restrict the file size that can be uploaded.

    I found that I can do it in

    public override List<Exception> Validate(HttpContextBase httpContext)
    

    by looking at the contentlength of the file from httpContext.Request.Files however the problem is that the file still seems to be uploaded to the server when submit is clicked. So if someone selects a really large file and clicks submit it starts uploading before Validate fires and tells them the selected file is too large.

    Is there a way to check the selected file size before it uploads to the server?

    Thanks

    Richy

  • Richy 8 posts 78 karma points
    Jul 13, 2016 @ 07:19
    Richy
    0

    I'm guessing there'll have to be some client side validation rather than server side but i'm unable to find any examples of client side validation with a contour form. Help!

  • Richy 8 posts 78 karma points
    Jul 13, 2016 @ 10:40
    Richy
    0

    Ok I'm now thinking this isn't possible as the file can't be accessed client side. The concern is people uploading large files to the site so am I right in thinking the only way around this is configuring IIS to restrict the maximum upload?

    Then I don't suppose it really matters what option I choose for validating the file extension.

  • Richy 8 posts 78 karma points
    Jul 13, 2016 @ 11:35
    Richy
    0

    I've been playing with the default fileupload control to try and understand how it behaves when sending large files. I've tried uploading a file just over the IIS default maximum allowed content length of 28mb and then files ranging in size 65mb, 200mb, 3gb.

    The smaller files 28mb, 65mb, 200mb when I click submit I see the uploading tool tip pop up in the bottom of the browser and this runs up to 100% and then I'm forwarded to a page not found page which I think is correct as it should throw a 404.13 error. However the 3gb file sits there uploading to about 30% then cycles back to 0% and keeps looping like that.

    My question is if the maximus allowed content length is 28mb why do the 65mb and 200mb files get to 100% and the 3gb file 30% as these are all above the 28mb limit?

    What exactly is happening when I click submit and it says uploading, for example when the 3gb file is 20% uploaded I don't see a 600mb reduction in disk space on the server? Where is it uploading to? Why does it keep cycling 0-30%?

    Thanks

    Richy

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Jul 14, 2016 @ 15:23
    Warren Buckley
    0

    Hi Richy,
    Umbraco Forms uses jQuery Validation as the clientside validation library.

    https://jqueryvalidation.org

    You could write your own jQuery custom validator and apply the new HTML data attribute on the file element template/view to ensure it gets invoked

    http://stackoverflow.com/questions/33096591/validate-file-extension-and-size-before-submitting-form

    More links on using JS to determine filesize of selected file

    http://stackoverflow.com/questions/3717793/javascript-file-upload-size-validation

    https://www.sanwebe.com/2013/10/check-input-file-size-before-submit-file-api-jquery

    In regards to the browser cycling between 0 & 30% for such a large 3GB file I am not entirely sure it would be doing that, perhaps request is timing out as opposed to the content length (file size) and thus the request starts over again?

    I hope this helps you in what you want to achieve.

    Thanks,
    Warren :)

Please Sign in or register to post replies

Write your reply to:

Draft