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

curl-php cURL 上传文件失败

WBOY
WBOYOriginal
2016-06-02 11:29:351146browse

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>

01.php

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

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

Statement:
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