C
C
chincharovpc2019-09-18 19:48:36
PHP
chincharovpc, 2019-09-18 19:48:36

Send GET or POST base64 request from Javascript to PHP?

There is a String received using the function, the
reader.readAsDataURL(blob)
size is somewhere around 500kb.
5d825f3dc7897331974474.png
I need to send this string using the API from JS to PHP using XMLHttpRequest.
Everything is ready, except that this string is not transmitted (apparently the volume is large)

Smaller strings are passed

How can I transfer it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2019-09-18
@chincharovpc

In two steps (more economical!):
1. https://github.com/eligrey/FileSaver.js/
2. https://stackoverflow.com/questions/23511792/attac...
You can do it in one:

var xhr = new XMLHttpRequest();
xhr.open('POST', 'someURLForTheUpload', true); //my url had the ID of the item that the blob corresponded to
xhr.responseType = 'Blob';
xhr.setRequestHeader("x-csrf-token",csrf); //if you are doing CSRF stuff
xhr.onload = function(e) { /*irrelevant code*/ };
xhr.send(blob);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question