UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Upload Button for images in Web app

    Scheduled Pinned Locked Moved App Development
    4 Posts 2 Posters 789 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • lmhL Offline
      lmh
      last edited by

      Dear all,
      in the web app I'm developing the user is supposed to upload an image via a input element:

      <label for="file">Upload</label>
      <input type="file"  accept="image/*" name="image" id="file"  onchange="loadFile(event)">
      

      This then prompts the JS function

      var loadFile = function(event) {
        var image = document.getElementById('pic');
        image.src = URL.createObjectURL(event.target.files[0]);
      };
      
      

      This works in all the browsers on my ubuntu desktop but not in the app itself on my phone. This screen opens, when I click the 'upload button'

      errorUBtouch.jpg

      Any idea what the problem is here would be much appreciated...

      K 1 Reply Last reply Reply Quote 0
      • K Offline
        kugiigi @lmh
        last edited by

        @lmh How are you creating the webapp? Are you embedding a webview in QML?
        If yes, you can check here. Content hub implementation is in here.

        lmhL 1 Reply Last reply Reply Quote 0
        • lmhL Offline
          lmh @kugiigi
          last edited by

          @kugiigi Thanks for the links. Will have a look at it tonight. I am coding in html/css/js and using clickable to create the ubuntu touch package/app. I think I found another solution here

          https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications

          1 Reply Last reply Reply Quote 0
          • lmhL Offline
            lmh
            last edited by

            I have solved the problem. The issues had nothing to do with my code. Just in case it helps anyone else: In the file

            yourappname.apparmor

            (which is automatically generated by clickable) you need to add the policy group "picture_files_read". I assumed "content_exchange" would suffice but it doesn't. So this issue is solved

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post