html-php How do I use curl to simulate a form with strings and files at the same time?

Source: Internet
Author: User
rt,php, trying to send both files and strings with curl, is to simulate a form that has a bunch of strings and files.

Reply content:

rt,php, trying to send both files and strings with curl, is to simulate a form that has a bunch of strings and files.

curl_setopt($curl_handle, CURLOPT_POST, 1);$args['file'] = '@/path/to/file';$args['a'] = 'blablabla...'; //and so oncurl_setopt($curl_handle, CURLOPT_POSTFIELDS, $args);

More content: Https://wiki.php.net/rfc/curl-file-upload

The default form is not POST capable of both strings and files, and you can consider strings to be GET passed through URLs, as well as POST files.

  • 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.