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

极简图床curl上传图片

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-06 19:39:161072瀏覽

上传图片至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;

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn