Home  >  Article  >  Backend Development  >  Simple example of php curl uploading files

Simple example of php curl uploading files

WBOY
WBOYOriginal
2016-07-25 08:58:081231browse
This article introduces a small example of using curl to upload files in PHP. Friends in need can refer to it.

To upload files in php, you can use the regular form submission method or curl.

Here is an example of uploading files using php curl:

<?php
    $file = array("upimg"=>"@E:/png.png");//文件路径,前面要加@,表明是文件上传.
    $curl = curl_init("http://localhost/a.php");
    curl_setopt($curl,CURLOPT_POST,true);
    curl_setopt($curl,CURLOPT_POSTFIELDS,$file);
    curl_exec($curl);
//by bbs.it-home.org
?>

Instructions: To upload files using curl, there is no need to create any forms, and the code is simpler.



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