PHPs base 64_decode is not converting base64 string to a real workable image file

后端 未结 4 1544
有刺的猬
有刺的猬 2021-01-28 04:26

Hello guys I successfully found a method that claims to make a file input file into a base 64 string in JavaScript so I successfully sent that base 64

string by JSON v

4条回答
  •  孤城傲影
    2021-01-28 04:58

    I think you should abandon your current methodology entirely and replace it with this:

    Then, on your server-side code, inspect the results like so:

    Look into move_uploaded_file() when you know where you want to put it.

    There are many benefits:

    • A real, binary file upload without the waste and overhead of 33% base-64, nor the CPU on each side to deal with it
    • An image input that accepts just images (accept="image/*")
    • Form can be submitted by screen readers and other browser controls, rather than just some button without context
    • No need for JavaScript at all!
    • Standard streaming uploads, for less memory usage on your server.
    • No need for the encoding/decoding of a potentially huge JSON blob.

提交回复
热议问题