I have this php code that sends a POST request containing a file:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://****/ocr_api/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('file'=> new CURLFile('/C:/Users/me/Downloads/test.pdf')),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
I copied this code from postman under the "code" options, so this should be the equivalent of it and work without issue? But it still doesnt.
request.files
shows an empty dictionary then doesnt make it further than that line
@app.route("/", methods=["POST"])
def accept_pdf():
print("HERE", request.files) ## SHOWS UP EMPTY AND STOPS HERE
pdf = request.files["file"]
filename = pdf.filename
print("FILENAME", filename)
Any help? Thank you