Drupal uses cURLPost to send an object

Source: Internet
Author: User
Tags drupal
As we all know, PHP cURL extensions can be used to simulate form submission. Drupal has the drupal_http_request function to execute an HTTP request. It can send a file via POST, but it is not as convenient as cURL. Here we will mainly explain how to Post a file to a remote server address in Drupal. Webpage Form table

As we all know, PHP cURL extensions can be used to simulate form submission. Drupal has the drupal_http_request function to execute an HTTP request. It can send a file via POST, but it is not as convenient as cURL. Here we will mainly explain how to Post a file to a remote server address in Drupal. Webpage Form table

As we all know, PHP cURL extensions can be used to simulate form submission. In Drupaldrupal_http_requestFunction to execute an HTTP request. It can send a file in POST mode, but it is not as convenient as cURL. Here we will mainly explain how to Post a file to a remote server address in Drupal.

Webpage Form

The preceding form contains the text box, password, check box, and file submission.

Drupal cURL simulate form submission POST

$ 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' => 'lixip ',
'Password' => '000000 ′,
'Rememberme' => '1 ′,
'Avatar '=>' @ '. $ filename,
);
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post );
$ Response = curl_exec ($ ch );

The value of $ response is the HTML output after the webpage Form is submitted.

(...)
Read the rest of Drupal sends a file (1 words) through the cURL Post method)

©Li Xi for lixphp, 2013. | Permalink | No comment | Add todel. icio. us
Post tags: curl, drupal, drupal_http_request, Form, Post, send file, submit Form, simulate Form

Feed enhanced by Better Feed from Ozh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.