Monday, July 25, 2011

Giving up on HTML5 file drag and drop.

I had a solution that 'mostly' worked in chrome, and 'mostly' worked in firefox, and then I find out safari, as usual goes off and does its own thing.

I then read QuirksMode multi-page rant on how bad this API is, and realized the real problem was trying to support this mess.
I'm pretty sure I had safari drag and drop working at first, but now? It refuses to accept files, my code never even gets the chance to 'accept' or 'reject'. Maybe I'm doing it wrong (though FF and chrome both work), though its so hard to tell. This whole API is a terrible terrible mess with no clear examples on how to use it, nor any sort of standardized test suite to prove it works on any given browser, which makes it even more likely that a bug was introduced, made me realize its a waste of my time trying to deal with it.


As I dig more into web development, it certainly seems like no one is at the helm, or whoever is at the helm of this crazy ship certainly has no interest in consistency, or even 'looking out' for the web developers.
If the W3C is really in 'charge' why aren't there a proper set of test suites that are run, (maybe they exist, but they must not be thorough with all the crazy nonsense I've seen between chrome and firefox.)


So for now, I went back to the <input> type everyone loves to hate, and that's type='file'.

Which in itself, is another big mess.

On chrome and safari, there is an 'OS' styled button that says "Choose file", with some room for the filename on the right.
On firefox, it is an old school square button that says 'browse', which has a text entry field on the left.

Chrome and safari (via webkit?) allow  a user to drop a file from their desktop onto the button.
Firefox does not allow this.

In firefox, the <input> can be sized with style, but then the button just gets bigger.
In webkit, the area gets bigger, but the button remains the same size. Most other styles are ignored.
Safari will never give you the results from multiple files being selected, only the first one.

Safari never sends the mime type in the POST, so, good luck with trying to figure that out, Firefox and Chrome bother to suss this out and report it.