0

I have a form that gets a name and an image (logo). I'm using angularjs as client side language and dropzonejs as image upload library. when the user clicks on Edit, I want him to see the image preview that he has uploaded previously. I used this for doing so. The problem is if I upload a new image after I preload the initial image, I couldn't see new image's preview. here is my preload image code. (There is an angular directive for it)

if(scope.initialFileAddress != null && scope.initialFileAddress != "")
      mockFile = {name: scope.initialFileName, size: 1000, type: "image/jpeg"}
      this.addFile.call(this, mockFile)
      this.options.thumbnail.call(this, mockFile, scope.initialFileAddress)
Community
  • 1
  • 1
elahehab
  • 325
  • 3
  • 16
  • I also get this error: Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': The argument is not a Blob. – elahehab Aug 04 '14 at 05:46
  • This method(readAsDataURL) is called in createThumbnail function in dropzonejs – elahehab Aug 04 '14 at 05:47

1 Answers1

2

The problem was in this line of code:

this.addFile.call(this, mockFile)

I should replace it with:

this.options.addedfile.call(this, mockFile)

This way this image is not added to the main list of files that will be uploaded. For my case this change did the work!

elahehab
  • 325
  • 3
  • 16