Home > Backend Development > PHP Tutorial > 请问一个关于用cURL实现文件下传的有关问题

请问一个关于用cURL实现文件下传的有关问题

WBOY
Release: 2016-06-13 12:51:57
Original
863 people have browsed it

请教一个关于用cURL实现文件上传的问题?


问题如题目,请大家帮忙解决下,我是刚刚开始学cURL的.

最好能带上测试案例附加源码!!

谢谢!!!!


------解决方案--------------------
http://curl.haxx.se/libcurl/c/post-callback.html
这里有一个现成的教程,自己用google翻译一下。
------解决方案--------------------
    $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_USERAGENT, "Mozilla/4.0 (compatible;)");
    curl_setopt($ch, CURLOPT_URL, _VIRUS_SCAN_URL);
    curl_setopt($ch, CURLOPT_POST, true);
    // same as 
    $post = array(
        "file_box"=>"@/path/to/myfile.jpg",
    );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
    $response = curl_exec($ch);
?>
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