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://codercto.com/courses/l/5.html

查看所有标签

我++

我++

威廉·J·米切尔 / 刘小虎等 / 中国建筑工业出版社 / 2006-6 / 50.00元

随着《我++——电子自我和互联城市》(Me++:The Cyborg Self And The Networked City)的出版,《比特之城》(City Of Bits)和《E-托邦》(E-topia)的作者完成了一套检验信息技术在日常生活中之衍生的非正式三部曲。威廉·J·米切尔描述了自马可尼以后的百年间无线技术的发展变化:网络的不断扩大,发送和接受装置的不断缩小。正如他所说,这就像“大人国重......一起来看看 《我++》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具