PHP curl_file_create函数
PHP 教程
· 2019-01-23 12:13:49
(PHP 5 >= 5.5.0)
curl_file_create — 创建一个 CURLFile 对象。
说明
CURLFile curl_file_create ( string $filename [, string $mimetype [, string $postname ]] )
创建一个 CURLFile 对象, 用与上传文件。
参数
filename
上传文件的路径
mimetype
文件的Mimetype
postname
文件名。
返回值
返回 CURLFile 对象。
实例
curl_file_create() 实例
<?php
/* http://example.com/upload.php:
<?php var_dump($_FILES); ?>
*/
// 创建一个 cURL 句柄
$ch = curl_init('http://example.com/upload.php');
// 创建一个 CURLFile 对象
$cfile = curl_file_create('cats.jpg','image/jpeg','test_name');
// 设置 POST 数据
$data = array('test_file' => $cfile);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// 执行句柄
curl_exec($ch);
?>
以上例程会输出:
array(1) {
["test_file"]=>
array(5) {
["name"]=>
string(9) "test_name"
["type"]=>
string(10) "image/jpeg"
["tmp_name"]=>
string(14) "/tmp/phpPC9Kbx"
["error"]=>
int(0)
["size"]=>
int(46334)
}
}
点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html
爆款:如何打造超级IP
【美】安妮塔•埃尔伯斯 / 杨雨 / 中信出版社 / 2016-1-10 / 49
哈佛商学院IP运营与产品管理方法论第一书,翻转长尾理论的重要著作! 电影大片、当红炸子鸡、百万畅销书背后的运营逻辑是什么? 《五十度灰》、Lady Gaga、维多利亚的秘密有何共同秘密? 漫威如何将蜘蛛侠、X战警、绿巨人打造成金矿? 皇马如何打造体育IP,一跃成为全球收 入最高的足球俱乐部? 爆款策略如何运用于电影、电视、音乐、出版、体育与商业各领域? ----......一起来看看 《爆款:如何打造超级IP》 这本书的介绍吧!