Copied to clipboard

Flag this post as spam?

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


  • Dave de Moel 121 posts 566 karma points c-trib
    Oct 21, 2015 @ 11:57
    Dave de Moel
    0

    Custom section upload form

    Hello, I have a question regarding file upload in a custom section in Umbraco.

    How do I do this? I currently have a form that works as long as I use a text field, but as soon as I try to upload a file the form object stays empty. What do I need to do to get files to upload. I am trying to do it with AngularJS as per the following example: http://www.nibble.be/?p=440

    If possible though, I'd rather use a normal Razor form, so if there is a way to do that then I'd like to know. :)

  • Dave de Moel 121 posts 566 karma points c-trib
    Oct 22, 2015 @ 10:18
    Dave de Moel
    0

    I have been checking the source code of Umbraco, and it seems they use FileReader upload a Base64 string to the server. Would I be correct in this assessment?

  • Comment author was deleted

    Oct 22, 2015 @ 13:07
  • Dave de Moel 121 posts 566 karma points c-trib
    Oct 23, 2015 @ 08:34
    Dave de Moel
    0

    That is great :) I almost have it working using that example, though I get the following error now:

    Error: Argument 'storeLocatorUploadController' is not a function, got undefined
    

    Though as far as I can tell I followed the code perfectly well.

    html call: <div id="content" ng-app="storeLocatorUploadApp" ng-controller="storeLocatorUploadController">

    and adding to the app: app.controller("storeLocatorUploadController", ["$scope", "storeLocatorApiService", storeLocatorUploadController]);

    And a link to the complete controller script

    Do you have an idea what might be going wrong?

  • Comment author was deleted

    Oct 23, 2015 @ 08:41

    Did you add a package manifest with the js files? SO that get registered when Umbraco starts?

  • Dave de Moel 121 posts 566 karma points c-trib
    Oct 23, 2015 @ 08:49
    Dave de Moel
    0

    Yeas I did, and I can see all the files as well, and they are in the same order.

    enter image description here

  • Dave de Moel 121 posts 566 karma points c-trib
    Oct 23, 2015 @ 09:15
    Dave de Moel
    0

    Could it have anything to do with the fact that Umbraco uses AngularJS V1.1.5? And if so, can I just add the latest version without breaking the rest of the backoffice?

  • Comment author was deleted

    Oct 23, 2015 @ 09:36

    Yeah if you targeted a newer version of Angular that won't work, and you can't just add a newer version

  • Dave de Moel 121 posts 566 karma points c-trib
    Oct 23, 2015 @ 09:41
    Dave de Moel
    0

    Hmm, yeah I just got to the same conclusion.... Tested the app and it "works" when I isolate it out of Umbraco. So now I need to figure out what I need to change to make it work with AngularJS v1.1.5

  • Dave de Moel 121 posts 566 karma points c-trib
    Oct 23, 2015 @ 09:57
    Dave de Moel
    0

    Can I use a custom app name, or do I need to use "Umbraco" as an app name for backoffice angular scripts?

    edit: hmmm, if I try that the entirety of umbraco collapses.... Then I get the error at the main controller.

  • Dave de Moel 121 posts 566 karma points c-trib
    Oct 29, 2015 @ 09:13
    Dave de Moel
    100

    In the end I made my own api controller. The link you provided did help me on the way, but due o version differences (I guess) I needed to do it in a slightly different way to make it work on the back end.

    But it works now by using jquery to fetch the file information, then I use a formdata object to send the data to the server where I use an UmbracoApiController with an async HttpRespnseMessage task that just fetches the data from the request.files and then I handle the rest.

    Thanks for setting me on the path to success !

  • Gordon Saxby 1354 posts 1615 karma points
    Mar 18, 2016 @ 12:00
    Gordon Saxby
    0

    This sounds like the exact same thing I am trying to achieve! Any chance of a view of your code :-)

    I have a custom section, need to allow users to upload a file which then needs to be processed / data extracted and written to a database.

  • Bendik Engebretsen 105 posts 199 karma points
    Nov 02, 2016 @ 20:44
    Bendik Engebretsen
    1

    If someone still struggles with this, I have just got it working:-) My receipe is here.

Please Sign in or register to post replies

Write your reply to:

Draft