Copied to clipboard

Flag this post as spam?

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


  • Travis 19 posts 99 karma points
    Nov 08, 2022 @ 14:54
    Travis
    0

    Uploading a file via Umbraco backoffice

    I'm currently working on a quick interface for uploading a file (wordpress export in JSON) and having some trouble getting it to work in the backoffice.

    I've tried two methods:

    1. Using Jon D. Jones method of bypassing Angular and just using an MVC controller, but it looks like my

      tags get stripped when it renders my view. I'm guessing this has to do with the backoffice being rendered by javascript and angular is removing the tags somehow.

    2. Creating a backoffice plugin using Angular from the official Umbraco documentation. I got this to display and mostly interact correctly, but I'm having trouble with the upload part. All the stuff I see from googling is using Upload.upload(), however when I reference this, it throws an error.

    I'm hoping someone can send me in the right direction...

    The upload function in my angular controller:

    vm.uploadFile = () => {
            vm.Message1 = "Uploading";
    
            request = Upload.upload({
                url: '/umbraco/backoffice/plugins/welcomedashboard/process',
                file: vm.importFile
            }).then(() => {
                vm.Message1 = "Completed " + new Date();
            });
        }
    

    HTML View

    <umb-control-group label="File"
                               description="File to upload">
                <input type="file" ng-model="vm.importFile" ngf-select ng-multiple="false" />
    
                <umb-button action="vm.uploadFile()"
                            type="button"
                            button-style="info"
                            state="vm.buttonState"
                            label-key="translate_upload">
    
                </umb-button>
            </umb-control-group>
    
  • Mehmet Avcı 55 posts 240 karma points
    Nov 11, 2022 @ 14:49
    Mehmet Avcı
    0

    Heya Travis,

    From what I have seen on you are trying to reach out a controller action.

    In order to do that you should use http.get/post or any other depending your action instead of Upload.upload (Honestly I don't know about Upload.Upload at all)

    You can find some more information here in the documentation.

    Regards,

    Mehmet

Please Sign in or register to post replies

Write your reply to:

Draft