如何使用curl命令将图片上传到极简图床?
- 内容介绍
- 文章标签
- 相关推荐
本文共计94个文字,预计阅读时间需要1分钟。
上传图片至特定网站的简化代码如下:
php
1.[代码][PHP]代码
<?php $data = base64_encode(file_get_contents('test.jpg')); $ch = curl_init('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;
本文共计94个文字,预计阅读时间需要1分钟。
上传图片至特定网站的简化代码如下:
php
1.[代码][PHP]代码
<?php $data = base64_encode(file_get_contents('test.jpg')); $ch = curl_init('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;

