Home > Backend Development > PHP Tutorial > curl-php cURL 上传文件失败

curl-php cURL 上传文件失败

WBOY
Release: 2016-06-02 11:29:35
Original
1146 people have browsed it

phpcurl

curlPost.php

<code> <?php $post = array(        'name' => 'wyjie',        'img'  => '@D:/debug.exe'        );    //cURL发送post请求    $ch = curl_init();    curl_setopt($ch, CURLOPT_URL, 'http://localhost/demo/demo/curl/01.php');    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    curl_setopt($ch, CURLOPT_POST, 1);    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);    $optput = curl_exec($ch);    curl_close($ch);    echo $optput; ?></code>
Copy after login

01.php

<code> <?php print_r($_POST);    print_r($_FILES); ?></code>
Copy after login

输出结果
Array ( [name] => wyjie [img] => @./debug.exe ) Array ( )

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template