Coder Social home page Coder Social logo

Comments (2)

yangfan0095 avatar yangfan0095 commented on June 9, 2024 2

#208 look this , it worked for me .🙂

from reqwest.

blizzardengle avatar blizzardengle commented on June 9, 2024

This should me marked as closed. Jquery's Ajax will work because it handles sending files for you. It will start with the latest API's like FormData and work all the way down to submitting the form in an iFrame.

Reqwest and any other Ajax function or API that relies on the traditional XMLHttpRequest can not submit forms that include files. When using ajax (or XMLHttpRequest really) you are responsible for preparing the forms data to send, usually using a serialize function, but you can not do that to a file; meaning you can not serialize a file for sending like you can with other inputs.

What you'll have to do is add a check to your code to see if the form attempting to be submitted has a file input in it. If so you must not try to send it with reqwest but instead use your own custom code to copy the form into an iframe and submit it hidden form the user. You then copy the iframes content after the submission and that becomes your response form the server. This is terribly complicated so I recommend searching Stack Overflow and blogs for help. Also, just FYI the "response" you get back from the iFrame is limited in the data (information) you'll get back. You wont have access to the whole XMLHttpRequest response for example.

from reqwest.

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.