Git Product home page Git Product logo

Comments (4)

markusslima avatar markusslima commented on August 16, 2024

The plugin is just to customize the input file, it will not upload a plugin. You are the one to apply the extra functionality.

from bootstrap-filestyle.

smartcorestudio avatar smartcorestudio commented on August 16, 2024

It's not about upload. It's about selecting the file. For example, native HTML input type="file" supports Drag-n-Drop in Firefox (maybe in other browsers too), but bootstrap-filestyle doesn't support it

from bootstrap-filestyle.

gpetrov avatar gpetrov commented on August 16, 2024

Any news on this one? It will be really useful to have drag & drop available for all browsers

from bootstrap-filestyle.

zenzei avatar zenzei commented on August 16, 2024

Hi.

I manage to get this beahviour working (native selection with drag & drop in browsers, without ajax or async uploads) with some minor tweaks to the js, following this idea http://www.quirksmode.org/dom/inputfile.html.

I'm not very good with git so I will paste the changes here. They are only minor style changes for the bootstrap-filestyle.js version 1.2.1. For simplicity replace lines 243 to 255 with these

            _self.$elementFilestyle = $('<div class="bootstrap-filestyle input-group"  style="position: absolute; top: 0px; left: 0px; z-index: 1;">' + html + '</div>');
            _self.$elementFilestyle.find('.group-span-filestyle').attr('tabindex', "0").keypress(function(e) {
            if (e.keyCode === 13 || e.charCode === 32) {
                _self.$elementFilestyle.find('label').click();
                    return false;
                }
            });

            // hidding input file and add filestyle
            _self.$element.css({
                '-moz-opacity': 1,
                'filter': 'alpha(opacity: 1)',
                'opacity': 0,
                'position': 'relative',
                'text-align': 'right',
                'z-index': 2
            }).attr('tabindex', "-1").addClass('form-control').wrap('<div style="position: relative;"></div>').after(_self.$elementFilestyle);

This works for me in IE 11, Chrome, Firefox and Safari for Windows (I don't have a Mac or older IE versions to test).

In my app I also add these lines to avoid leaving the page if the user wrongly try to drag & drop to a "not" input file, as the browser will try to open the file leaving your current page. I know it's not the puporse of this library, but I put it here cause I think is related.

$(document).on("dragover drop", function(e) {
  if (!$(e.target).is("input[type='file']")) {
    e.preventDefault();  //don't navigate to file on drop (if the target isn't an input type file) 
  }
});

Is an almost global denied to all drag&drop events as my app doesn't need any of these except for the file inputs, you will need to adjust this in your app. Here another link that could help for that http://stackoverflow.com/a/32044456.

Hope it helps anybod

from bootstrap-filestyle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.