G
G
gregorypetrov2018-03-13 17:19:25
PHP
gregorypetrov, 2018-03-13 17:19:25

How to AJAX send a file generated on the fly by a php script?

The site has a script that generates and returns a PDF from the data passed to it via POST -

example.com/make_pdf_file.php _


(The URL giving the PDF is always like this).

The task is to AJAX send the generated PDF content to another script, for example, this -

example.com/form_result_handler.php _


I can not understand the principle of how to do it. I suppose that the first step is to get the content of the file given by the make_pdf_file.php PDF generator into some variable, and then send it, but how?

Maybe someone faced such a task or have examples? Please help me navigate.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2018-03-13
@megafax

You can try to give the file in base64, and send it to a separate input. Naturally, your _FILES will be empty, since input[type=file] must be initiated only by the user, otherwise it is a security hole.
Those. You should end up with something like this:
But keep in mind that such a mechanism requires additional security checks, the integrity of the transferred file, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question