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

can't make it work on chrome 33.0.1750.117, macos 10.9 #157

Open
frumbert opened this issue Feb 25, 2014 · 0 comments
Open

can't make it work on chrome 33.0.1750.117, macos 10.9 #157

frumbert opened this issue Feb 25, 2014 · 0 comments

Comments

@frumbert
Copy link

I have abootstrap 3 / jquery 1.9.1 (with migrate 1.1.1) page with an <article> container. I want to be able to drop anywhere on that article in order to upload.

Chrome doesn't register anything on the console when one or more files are dropped, and nothing is transferred on the network. The various highlights I've put on docOver and stuff work, so it's starting to bind things.

No errors or warnings in console. I dropped a console.log(builder) before xhr.sendAsBinary(builder) - doesn't even hit the code.

var $container = $("article");
$container.filedrop({
    fallback_id: 'manual_upload',
    url: '/engine/listUpload.asp',
    paramname: 'userfile',
    withCredentials: false,
    data: { "stop": true },
    error: function(err, file) {
        switch(err) {
            case 'BrowserNotSupported':
                alert('browser does not support HTML5 drag and drop');
                break;
            case 'TooManyFiles':
                alert('too many files');
                break;
            case 'FileTooLarge':
                alert("one or more files were too big");
                break;
            case 'FileTypeNotAllowed':
                alert("You dropped un-uploadable file types");
                break;
            case 'FileExtensionNotAllowed':
                alert("Files with this extension are not allowed");
                break;
            default:
            alert("some error maybe " + err + "\n" + file);
                break;
        }
    },
    allowedfiletypes: ['image/jpeg','image/png','image/gif'],   // filetypes allowed by Content-Type.  Empty array means no restrictions
    allowedfileextensions: ['.jpg','.jpeg','.png','.gif'], // file extensions allowed. Empty array means no restrictions
    maxfiles: 10,
    maxfilesize: 20,
    queuefiles: 2,
    docOver: function() {
        $container.css("background-color", "rgba(255,128,0,.5)");
    },
    docLeave: function() {
        $container.css("background-color", "");
    },
    drop: function() {
        $container.css("background-color", "");
    },
    uploadStarted: function(i, file, len){
        console.log("uploadStarted", i,file,len);
    },
    uploadFinished: function(i, file, response, time) {
        console.log("uploadFinished", i, file, response, time);
    },
    afterAll: function() {
        console.log("seems to think everything is done now");
    }
});

I tried modifying the plugin to work out why sendasbinary wasn't working. I threw in some console junk.

  try {
  console.log("-33333333333333333333333333333-");
    if (XMLHttpRequest.prototype.sendAsBinary) {
  console.log("-------------!!!!!!!!!!!!------------");
        return;
    }
    XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
  console.log("-----?????????--------------??????????------");
      function byteValue(x) {
        return x.charCodeAt(0) & 0xff;
      }
      var ords = Array.prototype.map.call(datastr, byteValue);
      var ui8a = new Uint8Array(ords);

      // Not pretty: Chrome 22 deprecated sending ArrayBuffer, moving instead
      // to sending ArrayBufferView.  Sadly, no proper way to detect this
      // functionality has been discovered.  Happily, Chrome 22 also introduced
      // the base ArrayBufferView class, not present in Chrome 21.
      if ('ArrayBufferView' in window)
        this.send(ui8a);
      else
        this.send(ui8a.buffer);
    };
  } catch (e) {
      console.log("XXxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", e);
  }

My console reads -33333333333333333333333333333- and stops there. Doesn't even log inside an exception, or the function declaration. So it seems testing for XMLHttpRequest.prototype.sendAsBinary kills the object.

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

1 participant