I want to create a drag & drop upload file ember.js app, I'm trying to use ember-plupload, but I can't make the plupload work, here is my code:
<div class="dropzone" id=>
Drop to upload
Invalid
Uploading files. (%)
<h4>Upload Images</h4>
<p>
Drag and drop images onto this area to upload them or
<a id="upload-image">Add an Image.</a>
</p>
</div>
It's the sample template from plupload. And a route:
import Ember from "ember";
const get = Ember.get;
const set = Ember.set;
export default Ember.Route.extend({
actions: {
uploadImage: function (file) {
var product = this.modelFor('product');
var image = this.store.createRecord('image', {
product: product,
filename: get(file, 'name'),
filesize: get(file, 'size')
});
file.read().then(function (url) {
if (get(image, 'url') == null) {
set(image, 'url', url);
}
});
file.upload('/api/images/upload').then(function (response) {
set(image, 'url', response.headers.Location);
return image.save();
}, function () {
image.rollback();
});
}
}
});
Sample again. Finally there is the result, the page
Upload Images
Drag and drop images onto this area to upload them or Add an Image.
But I can't drag anything onto it. And a firebug log:
Instantiating FileInput...
Trying runtime: html5
Object {accept=[1], name="file", multiple=true, ...}
default mode: browser
selected mode: false
Runtime 'html5' failed to initialize
Trying runtime: html4
Object {accept=[1], name="file", multiple=true, ...}
default mode: browser
selected mode: false
Runtime 'html4' failed to initialize
Trying runtime: flash
Object {accept=[1], name="file", multiple=true, ...}
select_multiple: true (compatible modes: null)
drag_and_drop: true (compatible modes: null)
default mode: client
send_browser_cookies: false (compatible modes: client)
select_file: true (compatible modes: client)
selected mode: false
Runtime 'flash' failed to initialize
Trying runtime: silverlight
Object {accept=[1], name="file", multiple=true, ...}
select_multiple: true (compatible modes: null)
drag_and_drop: true (compatible modes: null)
default mode: browser
send_browser_cookies: false (compatible modes: client)
select_file: true (compatible modes: client)
Silverlight is not installed or minimal version (2.0.31005.0) requirement not met (not likely).
selected mode: false
Runtime 'silverlight' failed to initialize
Instantiating FileDrop...
Trying runtime: html5
Object {accept=[1], required_caps=Object, ...}
default mode: browser
selected mode: false
Runtime 'html5' failed to initialize
Trying runtime: html4
Object {accept=[1], required_caps=Object, ...}
default mode: browser
selected mode: false
Runtime 'html4' failed to initialize
Trying runtime: flash
Object {accept=[1], required_caps=Object, ...}
select_multiple: true (compatible modes: null)
drag_and_drop: true (compatible modes: null)
default mode: client
drag_and_drop: true (compatible modes: null)
send_browser_cookies: false (compatible modes: client)
select_file: true (compatible modes: client)
selected mode: false
Runtime 'flash' failed to initialize
Trying runtime: silverlight
Object {accept=[1], required_caps=Object, ...}
select_multiple: true (compatible modes: null)
drag_and_drop: true (compatible modes: null)
default mode: browser
drag_and_drop: true (compatible modes: null)
send_browser_cookies: false (compatible modes: client)
select_file: true (compatible modes: client)
Silverlight is not installed or minimal version (2.0.31005.0) requirement not met (not likely).
selected mode: false
Runtime 'silverlight' failed to initialize
What can I do in that case? Greetings, Rafał
Aucun commentaire:
Enregistrer un commentaire