We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently, we need to be a bit creative to attach files to a post request
// Create a boundary. We'll need it as we build the payload. $boundary = md5( time() . $ext ); // End of Line $eol = "\r\n"; // Construct the payload in multipart/form-data format $payload = ''; $payload .= '--' . $boundary; $payload .= $eol; $payload .= 'Content-Disposition: form-data; name="submitted_file"; filename="' . $name . '"' . $eol; $payload .= 'Content-Type: ' . $format . $eol; $payload .= 'Content-Transfer-Encoding: binary' . $eol; $payload .= $eol; $payload .= $contents; $payload .= $eol; $payload .= '--' . $boundary . '--'; $payload .= $eol . $eol; // Create args for wp_remote_request $args = array( 'headers' => array( 'accept' => 'application/json', 'content-type' => 'multipart/form-data;boundary=' . $boundary, ), ); // Call the standard request function and return it. return $this->request( $api_method, $params, $http_method, $payload, $args );
I would like to be able to pass an array of mixed objects and have it be handled as multipart form if it is a POST/PUT/OPTIONS/PATCH call
code like above
The text was updated successfully, but these errors were encountered:
Duplicate of #289 with possible solution via PR #313 ?
Sorry, something went wrong.
yes #313 will work let's close this and get that merged
Closing as duplicate of #289
No branches or pull requests
Currently, we need to be a bit creative to attach files to a post request
I would like to be able to pass an array of mixed objects and have it be handled as multipart form if it is a POST/PUT/OPTIONS/PATCH call
Describe alternatives you've considered
code like above
Additional context (optional)
The text was updated successfully, but these errors were encountered: