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:
-
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.
-
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>
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/110434-uploading-a-file-via-umbraco-backoffice