Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE9 Flash callback issues #46

Open
k3mist opened this issue Jul 15, 2013 · 2 comments
Open

IE9 Flash callback issues #46

k3mist opened this issue Jul 15, 2013 · 2 comments

Comments

@k3mist
Copy link

k3mist commented Jul 15, 2013

I am having problems in IE9 with the Flash FileReader callbacks that I can not resolve. After trying to figure this out over a weekend I found what I think may be the problem. I am using the FileAPI polyfill to get the files list in IE9 (which I imagine should not be an issue). This code should work I believe unless I really am doing something wrong here.

Filereader options

filereader:
    id: 'fileAPIProxy'
    filereader: '/assets/libs/webshims/vendor/filereader/filereader.swf'
    expressInstall: '/assets/libs/webshims/vendor/swfobject/expressinstall.swf'

Binding handler code (with feature detection removed)

   isImage = (file) ->
       file and typeof file.type isnt "undefined" and file.type.match('image.*') and file.name.match(/\.(gif|png|jpe?g)$/i)

   $(element).fileReader(viewModel.filereader).on(
      change: (event) ->
        file = FileAPI.getFiles(event)[0]
        if isImage(file)
          reader = new FileReader()
          reader.onload = (event) -> koPhoto.photo_uri(event.target.result)
          reader.readAsDataURL(file)
    )

The Flash callback that is issuing the JS error when readAsDataURL() is executed is below. This link references the Flash Callback problems in IE; http://zaalabs.com/2011/01/adobe-flash-externalinterface-issues-with-internet-explorer/

function __flash__addCallback(instance, name) {
  instance[name] = function () { 
    return eval(instance.CallFunction("<invoke name=\""+name+"\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments,0) + "</invoke>"));
  }
}
@matthiasleitner
Copy link

There should be no need to use the FileAPI polyfill.

Bind the change event in the callback function of the FileReader as described in the readme and you will be able to access the file using event.target.files.

Hope this helps.

dirty example working in IE9:

$("#input").fileReader
        id: "fileReaderSWFObject"
        filereader: "/flash/filereader.swf"
        callback: =>
          $("#input").change (e) =>
           # access e.target.files

@whatisboom
Copy link

resurrecting this... My callback is never firing, I get no feedback from the plugin even though debug mode is on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants