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. |