search

Home  >  Q&A  >  body text

javascript - ajax image file submitted together with text box data for upload processing

Select a local image file, enter some data in the input box and click Submit. After submission, an Uncaught TypeError: Illegal invocation error will be reported directly. Illegal call, the file cannot be used forData and cannot be placed in json

迷茫迷茫2794 days ago732

reply all(1)I'll reply

  • 某草草

    某草草2017-05-31 10:43:10

    If you want to submit the file using ajax, there are basically three ways
    1. You can encapsulate your file with formdata, and then put in the ajax data.
    2. You can use the jquery from plug-in to upload Wenjia directly.
    3. You can convert local files into base64 format, and then submit them in the same way as ordinary text formats. Then convert base64 to an image on the server side.

    reply
    0
  • Cancelreply