My version: issue accessing img in the previewHtml.
This commit is contained in:
parent
096bcb6284
commit
965d5e809c
1 changed files with 28 additions and 4 deletions
32
js/upload.js
32
js/upload.js
|
@ -1,14 +1,38 @@
|
||||||
|
var previewHtml =
|
||||||
|
'<div class="preview">' +
|
||||||
|
'<span class="imagePreview">' +
|
||||||
|
'<img /><span class="imageSuccess"></span>' +
|
||||||
|
'</span>' +
|
||||||
|
'<div class="imageProgress"><div class="progressBar"></div></div>' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
$('#drop').filedrop({
|
$('#drop').filedrop({
|
||||||
url: 'upload.php',
|
url: 'upload.php',
|
||||||
paramname: 'file',
|
paramname: 'file',
|
||||||
maxfiles: 4,
|
maxfiles: 4,
|
||||||
maxfilesize: 1,
|
maxfilesize: 1,
|
||||||
|
|
||||||
uploadFinished: function(i, file, response, time) {
|
|
||||||
|
|
||||||
},
|
|
||||||
beforeEach: function(file) {
|
beforeEach: function(file) {
|
||||||
alert('temp attempting upload') ;
|
// alert('temp attempting upload') ;
|
||||||
|
},
|
||||||
|
uploadStarted: function(i, file, len) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
|
||||||
|
reader.onload = function(e) {
|
||||||
|
alert(e.target.result);
|
||||||
|
$('img',$(previewHtml)).attr('src', e.target.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
$(previewHtml).appendTo($('#drop'));
|
||||||
|
|
||||||
|
$.data(file, $(previewHtml));l
|
||||||
|
},
|
||||||
|
progressUpdated: function(i, file, progress) {
|
||||||
|
$.data(file).find('.progressBar').width(progress);
|
||||||
|
},
|
||||||
|
uploadFinished: function(i, file, response, time) {
|
||||||
|
$.data(file).addClass('complete');
|
||||||
},
|
},
|
||||||
|
|
||||||
error: function(type, file) {
|
error: function(type, file) {
|
||||||
|
|
Loading…
Reference in a new issue