Skip to content
Advertisement

How to handle posted multipart/form-data when its send to PHP?

Rather simple question but I’m new to handling formdata and blobs. I need to handle a formdata file that contains both a blob and a string. The blob is first downloaded and then sent successfully to testPDF however in doing a var_dump of $_FILE[‘pdf_blob’] or $_POST[‘pdf_blob’] it comes out null, so probably I’m doing something wrong. Below the relevant ajax block

JavaScript

Logging in console shows me that pdf_blob is not empty before it is sent through ajax

JavaScript

Advertisement

Answer

Solved by adding a name to the field separate from the blob’s filename, like so: Javascript

JavaScript

then on PHP

JavaScript

var_dumping $_FILE directly or $_FILE[0] will always be empty

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement