Home > Backend Development > PHP Tutorial > Simple example of php curl uploading files

Simple example of php curl uploading files

WBOY
Release: 2016-07-25 08:58:08
Original
1240 people have browsed it
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
?>
Copy after login

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



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