Home > php教程 > php手册 > 极简图床curl上传图片

极简图床curl上传图片

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:39:16
Original
1099 people have browsed it

上传图片至http://yotuku.cn/,详见:http://blog.skyx.in/archives/164/ ?php$data = base64_encode(file_get_contents('test.jpg')); $ch = curl_init('http://yotuku.cn/upload?name='); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($

上传图片至http://yotuku.cn/,详见: http://blog.skyx.in/archives/164/

<?php
$data = base64_encode(file_get_contents('test.jpg'));
 
$ch = curl_init('http://yotuku.cn/upload?name=');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: text/plain',                                                                                
    'Content-Length: ' . strlen($data))                                                                       
);                                                                                                                   
 
$result = curl_exec($ch);
echo $result;
Copy after login

Related labels:
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
Latest Issues
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template