GithubHelp home page GithubHelp logo

Comments (5)

ProgerXP avatar ProgerXP commented on June 10, 2024

This is not always possible. Actually, the only case when iframe will be used is for legacy upload (IE, some Opera). For others AJAX will always be used but not in all browsers you have access to raw data (e.g. not in Safari 5).

The best you can do, if you need to send the data as MPFD - implement your own event handler for send that instead of calling sendTo('url') will readData() (http://filedropjs.org/#fm) and send it via XHR. However, with this you will lose support of browsers not able to read raw data. But you will retain support for iframe upload since it's always MPFD.

from filedrop.

rchrd2 avatar rchrd2 commented on June 10, 2024

+1 to this question.

@mgkimsal, did you end up implementing this suggestion? Do you have sample code?

@ProgerXP, I also think it would be helpful to have a flag to force multipart/form-data. I think there are advantages to that, such as keeping the original filename. We are using Django-Rest-Framework, and it doesn't support Application/Octet-Stream out of the box. Thank you.

from filedrop.

ProgerXP avatar ProgerXP commented on June 10, 2024

@rchrd2 There's nothing to "force" because AJAX uses no standard form upload. Your case is just special and you won't need most of FileDrop features anyway (at least those which support legacy upload). This way I suggest you handle actual upload with your own custom code - FIleDrop has got a bunch of data reading methods that you can use.

Here's a high level idea: create a HTML5 (drop-only) zone: http://filedropjs.org/#pure, listen to send and then create your own XMLHttpRequest, if you want it to use standard FileDrop events (error, progress, done) - call zone.hookXHR(xhr), set up your Django headers, read data from supplied files and construct MPFD, then send the XHR.

The hardest part of this would be to build MPFD by hand but I can't see any way around it - if you need to keep original file name, etc. you have to have an <input type=file> and that input should have the dropped file selected which I don't think is even possible without user interaction.

On the other hand, if you need MPFD that badly why do you need FileDrop at all? You can just make a regular <form><input type=file onchange="this.parentNode.submit()"></form> and it will be droppable in Firefox and Chrome (possibly others) working as you'd expect.

from filedrop.

rchrd2 avatar rchrd2 commented on June 10, 2024

Thanks for your feedback.

from filedrop.

mgkimsal avatar mgkimsal commented on June 10, 2024

I did not - I'm revisiting this next week and will reevaluate how we handle this. Thank you all for the input.

from filedrop.

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.