From 965d5e809c3083390176e57379761add33095165 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 2 Nov 2011 12:45:37 -0400 Subject: [PATCH] My version: issue accessing img in the previewHtml. --- js/upload.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/js/upload.js b/js/upload.js index e9b5dc6..9cb7a73 100644 --- a/js/upload.js +++ b/js/upload.js @@ -1,14 +1,38 @@ +var previewHtml = +'
' + + '' + + '' + + '' + + '
' + +'
'; + $('#drop').filedrop({ url: 'upload.php', paramname: 'file', maxfiles: 4, maxfilesize: 1, - uploadFinished: function(i, file, response, time) { - + beforeEach: function(file) { + // alert('temp attempting upload') ; }, - beforeEach: function(file) { - 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) {