Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8912373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:10:57+00:00 2026-06-15T04:10:57+00:00

Can someone provide code examples or documentation on implementing a form with a file

  • 0

Can someone provide code examples or documentation on implementing a form with a file field using EmberJS and Ember Data?

I’m familiar with Ember Data already but I’m not sure how to implement file-uploads correctly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:10:58+00:00Added an answer on June 15, 2026 at 4:10 am

    Here is part of an ember-data adapter I wrote to do file uploads (same server -not cross domain)

    DS.DjangoRESTAdapter = DS.RESTAdapter.extend({
            bulkCommit: false,
    
            createRecord: function(store, type, record) {
                var root = this.rootForType(type), json = {};
    
                var data = new FormData();
                data.append('username', record.get('username'));
                data.append('attachment', record.get('attachment'));
    
                this.django_file_ajax('http://localhost:8000/people/new/', "POST", {
                    data: data,
                    context: this,
                    success: function(pre_json) {
                        json[root] = pre_json;
                        this.didCreateRecord(store, type, record, json);
                    }
                });
            },
    
            django_file_ajax: function(url, type, hash) {
                hash.url = url;
                hash.type = type;
                hash.contentType = false;
                hash.processData = false;
                hash.context = this;
    
                jQuery.ajax(hash);
            }
    
        });
    
    })();
    

    It’s not IE8 friendly as is because I’m using the “FormData” helper to do multipart file upload but it’s a good proof of concept.

    Here is the ember-data model to go w/ the above adapter

    PersonApp.Person = DS.Model.extend({
      id: DS.attr('number'),
      username: DS.attr('string'),
      attachment: DS.attr('string')
    });
    

    Here is the handlebars template

    <script type="text/x-handlebars" data-template-name="person">
    {{view PersonApp.UploadFileView name="logo_image" contentBinding="content"}}
    </script>
    

    Here is the custom ember view

    PersonApp.PersonView = Ember.View.extend({
      templateName: 'person'
    });
    
    PersonApp.UploadFileView = Ember.TextField.extend({
        type: 'file',
        attributeBindings: ['name'],
        change: function(evt) {
          var self = this;
          var input = evt.target;
          if (input.files && input.files[0]) {
            var reader = new FileReader();
            var that = this;
            reader.onload = function(e) {
              var fileToUpload = e.srcElement.result;
              var person = PersonApp.Person.createRecord({ username: 'heyo', attachment: fileToUpload });
              self.get('controller.target').get('store').commit();
            }
            reader.readAsDataURL(input.files[0]);
          }
        }
    });
    

    If you want to see a full blown spike with this in action checkout a multi file upload example I did recently.

    https://github.com/toranb/ember-file-upload

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone point me out to some C# code examples or provide some code,
Hey Guys! Me again! Can someone provide me with some example code of how
The AppDomain.TypeResolve is mysterious in my eyes. Can someone provide a sample code that
Can someone provide an example of how to load a .svg file and display
Can someone provide practical, everyday examples of event bubbling and event capturing in jQuery/javascript?
Hope someone can provide some guidance - i've been using android sax parser with
I'm new to this kabeja package so please can some one provide code example
Can someone provide a quick top level explanation of how Valgrind works? An example:
Can someone provide basic sample / link for MVP Framework. Need to design a
Can someone provide a working example in which stored procedure returns a recordset and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.