I'm trying to send a post request to a php file that has post data and a file upload, here is the contents of what I am sending, the code for setting the headers, the php file I have, and what I am getting back from the php file: (the [image file content] is a placeholder for the binary data of the image file I am sending)
My problem is that neither $_POST & $_FILES are showing empty arrays. I am trying to figure out how to fix that.
//data I am sending to the server:
--boundary content-disposition: post; name='param1' value1 --boundary content-disposition: post; name='field2' value2 --boundary content-disposition: post; name='field3' value3 --boundary content-disposition: form-data; name='file'; filename='app/native/assets/sampleFile.jpg' Content-Type: image/jpg Content-Transfer-Encoding: binary [image file content] --boundary-- -----------------------------------------------------
for my headers, I have:
request.setRawHeader("Content-Type", "mulipart/form-data, boundary=boundary");
//data holds the string above
request.setRawHeader("Content-Length", QString::number(data.length()).toAscii());
php file:
<?php
echo "\npost:\n\n";
print_r($_POST);
echo "\nfiles:\n\n";
print_r($_FILES);
?>
result from php file:
post: Array ( ) files: Array ( )
multipart/form-data
is mulipart. tryvar_dump
ing the$_REQUEST
variable – pocesar