How to convert base64 pictures so that they can be uploaded through ajax

as shown in the title:

how do I convert base64 images into objects that can be uploaded through ajax? I got the base64 code after I gave it to toDataURL through canvas, but now when I"m about to upload it, I"m stupid, trying to solve

.
Mar.14,2021

  1. on computers, there is always a priority binary system, and storage and transmission takes up a small amount of space. Octal, hexadecimal, and string, for example, are all easy for human beings to understand.
  2. the same is true for uploading images. Binary (blob) is not easy to write and display directly in the tag, so you will think of transferring out base64 and ObjectURL, and then stuffing it into img. Binary is still recommended for transmission.
  3. of course, if the back-end children's shoes say that he wants to use strings to store them, then there is nothing he can do about it, so give it to him; of course, this is generally hypothetical.
  4. Canvas has a native toBlob, that is usually stuffed into the FormData and then passed by adding a few necessary fields. Specific you go to the forum search, said a lot of should be able to find the code directly.

base64 is just a string ajax passing a string
it should be noted that the string may greatly exceed the maximum limit of the request


see https://codeshelper.com/a/11.


you can send base64 directly to your back end and let them receive it.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2aeb2-2ba38.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2aeb2-2ba38.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?