In case you are sending a string, urlencode() it. Otherwise if array, it should be key=>value paired and the Content-type
header is automatically set to multipart/form-data
.
Also, you don’t have to create extra functions to build the query for your arrays, you already have that:
$query = http_build_query($data, '', '&');
Related Posts:
- How do I get a YouTube video thumbnail from the YouTube API?
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- PHP + curl, HTTP POST sample code?
- Can curl make a connection to any TCP ports, not just HTTP/HTTPS?
- Call to undefined function curl_init().?
- How do I get a YouTube video thumbnail from the YouTube API?
- CURL ERROR: Recv failure: Connection reset by peer – PHP Curl
- cURL error 60: SSL certificate: unable to get local issuer certificate
- HTTP Error 411, The request must be chunked or have a content length
- PHP cURL custom headers
- PHP $_POST not working?
- PHP cURL HTTP PUT
- file_get_contents( ) not working
- Error:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
- How to POST JSON Data With PHP cURL?
- cURL request in Laravel
- Sending POST data without form
- PHP Redirect with POST data
- POST an array from an HTML form without javascript
- How to avoid Request Entity Too Large 413 error
- Array to String PHP?
- How to fix ‘Notice: Undefined index:’ in PHP form action
- How to fix “Headers already sent” error in PHP
- PDOException: SQLSTATE[HY000] [2002] No such file or directory
- How do I get a file extension in PHP?
- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
- Convert a PHP object to an associative array
- XAMPP Port 80 in use by “Unable to open process” with PID 4
- How to parse a CSV file using PHP
- Cannot use object of type stdClass as array?
- Is a new line = \n OR \r\n?
- Email Not Sending from Byethost Hosting
- break out of if and foreach
- Redirect vs RedirectMatch
- Illegal string offset Warning PHP
- mysqli_real_connect(): (HY000/2002): No such file or directory
- Deleting an element from an array in PHP
- Converting string to Date and DateTime
- How can I do ‘insert if not exists’ in MySQL?
- The localhost page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500
- What is the difference between the ‘www’ folder and ‘htdocs’ folder?
- Notice: Trying to get property of non-object error
- undefined offset PHP error
- Call to undefined function mysql_query() with Login
- Is there a difference between the UTC and Etc/UTC time zones?
- What is Options +FollowSymLinks?
- Fatal error: Call to a member function prepare() on null
- PHP mail not working for some reason
- move_uploaded_file gives “failed to open stream: Permission denied” error
- Call to undefined method mysqli_stmt::get_result
- How to reformat date in PHP?
- Cannot simply use PostgreSQL table name (“relation does not exist”)
- How to read if a checkbox is checked in PHP?
- How do I expire a PHP session after 30 minutes?
- In_array not working
- How to make a countdown using PHP
- how to get id from URL using php
- Fatal error: Cannot use object of type mysqli_result
- mysql_field_name to the new mysqli
- MAMP “Apache couldn’t be started because port is in use.” AND “Can’t connect to local MySQL server through /tmp/mysql.sock
- mysqli_select_db() expects parameter 1 to be mysqli, string given
- Remove all special characters from a string
- how to convert object into string in php
- PHP Fatal error: Call to undefined function mssql_connect()
- Call to a member function on null?
- how to ping ip addresses in php and give results
- do_shortcode not working
- Only variable references should be returned by reference – Codeigniter
- PHP Unset Session Variable
- “Fatal error: Cannot redeclare function”
- php get all url variables
- How to remove unused dependencies from composer?
- Laravel 5 Clear Views Cache
- how to get date of yesterday using php?
- phpinfo() is not working on my CentOS server
- How can I fetch all items from a DynamoDB table without specifying the primary key?
- How to extract and access data from JSON with PHP?
- How to convert array to SimpleXML
- WordPress query single post by slug
- TCPDF ERROR: Some data has already been output, can’t send PDF file
- Limit String Length
- How to run PHP locally on MacOS
- Call PHP function from jQuery?
- PhpMailer SMTP NOTICE: EOF caught while checking if connected
- Facebook – Error parsing input URL, no data was cached, or no data was scraped
- What is the meaning of sprintf(): Too few arguments
- Paypal IPN Verification Postback with HTTPS
- Using PHP 7 with WAMP
- Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given… what I do wrong?
- PHP: bootstrap.php
- Display array values in PHP
- Php create a file if not exists
- Page redirect after certain time PHP
- Check if $_POST exists
- PHP syntax question: What does the question mark and colon mean? [duplicate]
- PHP & Case Sensitivity
- PHP Header redirect not working [duplicate]
- PHP – Fatal error: Unsupported operand types
- update post meta wordpress
- cURL error 6 on news area, and also won’t auto update