This article to introduce a Drupal through the Curl post to send a file implementation, if you are using Drupal cms do not go into the reference oh.
It is well known that PHP's curl extension can be used to simulate form submissions. There is a drupal_http_request function in Drupal to execute an HTTP request that can send a file by post, but it is not as easy to use as curl. Here we mainly explain how to post a file to a remote server address in Drupal.
Web Form Forms
The code is as follows |
Copy Code |
|
The above form contains a presentation text box, a password, a check box, and a file in the form of a submission.
Drupal Curl Demo Form Submit post
The code is as follows |
Copy Code |
$url = ' http://blog.lixiphp.com/demo/http_request/post.php '; $ch = Curl_init (); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, curlopt_verbose, 0); curl_setopt ($ch, Curlopt_returntransfer, true); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_post, true); $post = Array ( ' Username ' = ' lixiphp ', ' Password ' = ' 123456′, ' RememberMe ' = ' 1′, ' Avatar ' = ' @ '. $filename, ); curl_setopt ($ch, Curlopt_postfields, $post); $response = curl_exec ($ch); $response |
The value is the HTML that is output after the page form form is submitted.
http://www.bkjia.com/PHPjc/633136.html www.bkjia.com true http://www.bkjia.com/PHPjc/633136.html techarticle This article to introduce a Drupal through the Curl post to send a file implementation, if you are using Drupal cms do not go into the reference oh. It is well known that PHP's curl extension can ...