本文整理汇总了PHP中curl::addFile方法的典型用法代码示例。如果您正苦于以下问题:PHP curl::addFile方法的具体用法?PHP curl::addFile怎么用?PHP curl::addFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curl
的用法示例。
在下文中一共展示了curl::addFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setting
public function setting()
{
$data = array('id' => intval($this->user['id']), 'password' => trim($this->input['password']), 'password_again' => trim($this->input['password_again']), 'old_password' => trim($this->input['old_password']));
if ($data['password'] && $data['password'] != $data['password_again']) {
$this->ReportError('两次输入的密码不一样');
}
$curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir']);
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addRequestData('a', 'update_password');
foreach ($data as $key => $val) {
$curl->addRequestData($key, $val);
}
if ($_FILES['Filedata']) {
$curl->addFile($_FILES);
}
$return = $curl->request('member.php');
if ($return && $return[0]) {
if ($return[0]['error'] == -1) {
$this->ReportError('原始密码错误');
}
}
$this->redirect('更新成功');
}
示例2: __destruct
}
public function __destruct()
{
parent::__destruct();
}
public function convert()
{
global $gGlobalConfig;
include_once ROOT_PATH . 'lib/class/curl.class.php';
if ($gGlobalConfig['App_officeconvert']) {
$curl = new curl($gGlobalConfig['App_officeconvert']['host'], $gGlobalConfig['App_officeconvert']['dir']);
}
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addRequestData('custom_appid', CUSTOM_APPID);
$curl->addRequestData('custom_appkey', CUSTOM_APPKEY);
$curl->addFile($_FILES);
$result = $curl->request('convert.php');
//var_dump($result);exit;
$path = 'cache/word/zip_' . uniqid() . '/';
$zipDir = ROOT_PATH . $path;
$return = array();
if (hg_mkdir($zipDir) && is_writeable($zipDir)) {
$zipFile = $zipDir . 'word.zip';
file_put_contents($zipFile, $result);
$unzipDir = $zipDir . 'unzip/';
if (hg_mkdir($unzipDir) && is_writeable($unzipDir)) {
$unzipCmd = ' unzip ' . $zipFile . ' -d ' . realpath($unzipDir);
exec($unzipCmd);
$rmZip = ' rm -f ' . $zipFile;
exec($rmZip);
示例3: __destruct
}
public function __destruct()
{
parent::__destruct();
}
/**
* 转换word文档
*/
public function convert()
{
$app_id = isset($this->input['custom_appid']) ? trim($this->input['custom_appid']) : '';
$app_key = isset($this->input['custom_appkey']) ? trim($this->input['custom_appkey']) : '';
if (empty($app_id) || empty($app_key)) {
$this->errorOutput(PARAM_WRONG);
}
//先验证是否有权限
$auth = new Auth();
$auth_info = $auth->getAccessToken($app_id, $app_key);
if (!$auth_info) {
$this->errorOutput(NO_AUTH);
}
//处理上传的word文档
$gGlobalConfig['officeconvert'] = array('host' => '10.0.1.59:8080', 'dir' => 'officeConverter/');
$curl = new curl($gGlobalConfig['officeconvert']['host'], $gGlobalConfig['officeconvert']['dir']);
$curl->setSubmitType('post');
$curl->setReturnFormat('str');
$curl->initPostData();
$curl->addFile($_FILES);
$curl->addRequestData('custom_appid', $app_id);
$curl->addRequestData('custom_appkey', $app_key);
示例4: upload
public function upload()
{
if ($_FILES['videofile']) {
$this->errorOutput('没有视频文件');
}
if (!($server = $this->select_server())) {
$this->errorOutput('服务器已经满,不能上传视频,请稍等片刻');
}
$curl = new curl($server['host'], $server['dir']);
$curl->setSubmitType('post');
$curl->initPostData();
$curl->addFile($_FILES);
$info = $curl->request('create.php');
}
示例5: uploadToVideoServer
public function uploadToVideoServer($file, $title, $brief)
{
$curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addFile($file);
$curl->addRequestData('title', $title);
$curl->addRequestData('comment', $brief);
$curl->addRequestData('vod_leixing', 2);
$ret = $curl->request('create.php');
return $ret[0];
}
示例6: uploadToVideoServer
/**
*
* @Description 视频上传
*/
public function uploadToVideoServer($file, $title = '', $brief = '', $vod_lexing = 1)
{
$curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addFile($file);
$curl->addRequestData('title', $title);
$curl->addRequestData('comment', $brief);
$curl->addRequestData('vod_leixing', $vod_lexing);
//网页传的视频类型是1,手机传的视频是2
$curl->addRequestData('app_uniqueid', APP_UNIQUEID);
$curl->addRequestData('mod_uniqueid', MOD_UNIQUEID);
$ret = $curl->request('create.php');
return $ret[0];
}
示例7: updateAccount
public function updateAccount($data, $file = '', $id)
{
//查询帐户id
$sql = 'SELECT account_id FROM ' . DB_PREFIX . 'reporter WHERE id=' . $id;
$ret = $this->db->query_first($sql);
$account_id = $ret['account_id'];
if (!$account_id) {
return false;
}
$curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir'] . 'admin/');
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addRequestData('a', 'update');
if ($file) {
$curl->addFile($file);
}
$curl->addRequestData('id', $account_id);
$curl->addRequestData('user_name', $data['account']);
$curl->addRequestData('password', $data['password']);
$curl->addRequestData('brief', $data['brief']);
if (is_array($data['role_id'])) {
foreach ($data['role_id'] as $key => $val) {
$curl->addRequestData('admin_role_id[' . $key . ']', $val);
}
} else {
$curl->addRequestData('admin_role_id[]', $data['role_id']);
}
$curl->addRequestData('cardid', $data['card_id']);
$curl->addRequestData('domain', $data['domain']);
$ret = $curl->request('admin_update.php');
return $ret[0];
}
示例8: create
//.........这里部分代码省略.........
foreach (${$key} as $keyy => $valuee) {
$pic_date[$keyy][$key] = $valuee;
}
}
foreach ($pic_date as $key => $value) {
$pictypetmp = explode('.', $value['name']);
$picfiletype = strtolower($pictypetmp[count($pictypetmp) - 1]);
if (in_array($picfiletype, $material_type['img'])) {
$file_square['Filedata'] = $value;
$material_square = $this->mMaterial->addMaterial($file_square, $id);
$picture['host'] = $material_square['host'];
$picture['dir'] = $material_square['dir'];
$picture['filepath'] = $material_square['filepath'];
$picture['filename'] = $material_square['filename'];
$picture['typeid'] = 1;
$update_data = array_merge($update_data, $picture);
$resultfiles = $this->messagereceived->updatefiles($update_data);
unset($material_square);
unset($picture);
} else {
$this->errorOutput(IMGUPLOAD_W);
}
}
}
//附件的处理
if (is_array($_FILES['annex']['name'])) {
$annex_date = array();
foreach ($_FILES['annex'] as $key => $value) {
${$key} = $value;
foreach (${$key} as $keyy => $valuee) {
$annex_date[$keyy][$key] = $valuee;
}
}
foreach ($annex_date as $key => $value) {
$annextypetmp = explode('.', $value['name']);
$annexfiletype = strtolower($annextypetmp[count($annextypetmp) - 1]);
if (in_array($annexfiletype, $material_type['doc'])) {
$file_square['Filedata'] = $value;
$material_square = $this->mMaterial->addMaterial($file_square, $id);
$annex['host'] = $material_square['host'];
$annex['dir'] = $material_square['dir'];
$annex['filepath'] = $material_square['filepath'];
$annex['filename'] = $material_square['filename'];
$annex['typeid'] = 3;
$update_data = array_merge($update_data, $annex);
$resultfiles = $this->messagereceived->updatefiles($update_data);
unset($material_square);
unset($annex);
} else {
$this->errorOutput(IMGUPLOAD_D);
}
}
}
//视频的处理
if ($_FILES['video']['name']) {
$_FILES['videofile'] = array();
$video_date = array();
foreach ($_FILES['video'] as $key => $value) {
${$key} = $value;
foreach (${$key} as $keyy => $valuee) {
$video_date[$keyy][$key] = $valuee;
}
}
$curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
if (!$curl) {
$this->errorOutput(MSERVER_LOST);
}
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addRequestData('vod_leixing', $this->settings['m_r_leiixng']['vod_leixing']);
foreach ($video_date as $key => $value) {
$_FILES['videofile'] = $value;
$curl->addFile($_FILES);
$result = $curl->request('create.php');
if (!$result) {
$this->errorOutput('上传失败');
} else {
//基础字段
$info = $result[0];
$video = array('host' => $info['protocol'], 'dir' => $info['host'], 'filepath' => $info['dir'], 'filename' => $info['file_name'], 'typeid' => 2);
//序列化字段
$video_back = array('vid' => $info['id'], 'type' => $info['type'], 'pic' => $info['img']['host'] . $info['img']['dir'] . $info['img']['filepath'] . $info['img']['filename']);
//返回数据传回数组
$update_data['backup'] = $video_back ? @serialize($video_back) : '';
$update_data = array_merge($update_data, $video);
$resultfiles = $this->messagereceived->updatefiles($update_data);
unset($video_back);
unset($video);
}
unset($result);
}
}
} else {
$updateData = true;
}
$this->addItem($updateData);
$this->output();
}
}
示例9: upload_video
public function upload_video(&$files, $title)
{
$videos = array();
if ($files['videofile']) {
$max_size = ini_get('upload_max_filesize');
if ($max_size) {
if ($files['videofile']['size'] > $max_size * 1024 * 1024) {
return array('error' => '上传视频不能超过' . $max_size . 'M');
}
}
if (!$this->settings['App_livmedia']) {
return array('error' => 'NO_APP_LIVMEDIA');
}
$curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addFile($files);
$curl->addRequestData('title', $title);
$curl->addRequestData('comment', '');
$curl->addRequestData('vod_leixing', 2);
$ret = $curl->request('create.php');
isset($ret[0]) && ($ret = $ret[0]);
if ($ret) {
$ret['video_mp4'] = $ret['protocol'] . $ret['host'] . '/' . $ret['dir'] . $ret['file_name'] . '.' . $ret['type'];
$ret['video_m3u8'] = $ret['protocol'] . $ret['host'] . '/' . $ret['dir'] . $ret['file_name'] . '.m3u8';
$videos[] = $ret;
$video_type = $_FILES['videofile']['type'];
if (strstr($video_type, 'audio')) {
$videos['is_audio'] = 1;
$videos['upload_type'] = '音频';
}
} else {
//return array('error' => 'VIDEO_UPLOAD_ERROR');
}
unset($files['videofile']);
}
return $videos;
}
示例10: auth_update
/**
*
* @Description 系统用户更新
* @author Kin
* @date 2013-7-3 上午09:26:46
*/
private function auth_update($id, $name, $password, $role, $org, $avatar = '')
{
if (!$id || !$name || !$role || !$org) {
return false;
}
$curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir'] . 'admin/');
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addRequestData('a', 'register');
$curl->addRequestData('app_uniqueid', APP_UNIQUEID);
$curl->addRequestData('id', $id);
$curl->addRequestData('user_name', $name);
$curl->addRequestData('password', $password);
$curl->addRequestData('admin_role_id', $role);
$curl->addRequestData('father_org_id', $org);
if ($avatar) {
$curl->addFile($avatar);
}
$ret = $curl->request('admin_update.php');
$ret = $ret[0];
return $ret;
}
示例11: curl
<?php
require 'global.php';
require ROOT_PATH . 'lib/class/curl.class.php';
$curl = new curl($gGlobalConfig['officeconvert']['host'], $gGlobalConfig['officeconvert']['dir']);
$curl->setSubmitType('post');
$curl->setReturnFormat('str');
$curl->initPostData();
//$curl->setCurlTimeOut(60 * 2);
$curl->setClient(CUSTOM_APPID, CUSTOM_APPKEY);
$curl->addFile($_FILES);
$result = $curl->request('convert');
if (!$result) {
echo json_encode(array('error' => true));
exit;
}
$path = 'cache/word/zip_' . uniqid() . '/';
$zipDir = ROOT_PATH . $path;
if (hg_mkdir($zipDir) && is_writeable($zipDir)) {
$zipFile = $zipDir . 'word.zip';
file_put_contents($zipFile, $result);
$unzipDir = $zipDir . 'unzip/';
if (hg_mkdir($unzipDir) && is_writeable($unzipDir)) {
$unzipCmd = ' unzip ' . $zipFile . ' -d ' . realpath($unzipDir);
exec($unzipCmd);
$rmZip = ' rm -f ' . $zipFile;
exec($rmZip);
echo json_encode(array('ok' => 1, 'path' => $path . 'unzip/', 'url' => $path . 'unzip/index.html'));
exit;
}
}
示例12: create
/**
* 创建视频
* @param Array $data 相关属性
* @param Array $file 视频文件
*/
public function create($data, $file)
{
global $gGlobalConfig;
$curl = new curl($gGlobalConfig['App_mediaserver']['host'], $gGlobalConfig['App_mediaserver']['dir'] . 'admin/');
if (!$curl) {
return array();
}
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
if ($data && is_array($data)) {
foreach ($data as $k => $v) {
$curl->addRequestData($k, $v);
}
}
$curl->addFile($file);
$ret = $curl->request('create.php');
return $ret[0];
}
示例13: upload_video
/**
* 上传视频操作
*/
public function upload_video()
{
$config = array('protocol' => 'http://', 'host' => 'vapi1.dev.hogesoft.com:233', 'dir' => '', 'token' => 'aldkj12321aasd', 'port' => '');
$curl = new curl($config['host'], $config['dir']);
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addFile($_FILES);
$result = $curl->request('create.php');
if (!$result) {
$out = json_encode(array('error' => 1, 'msg' => '上传失败'));
} else {
//本地化视频到数据库中
$info = $result[0];
$img = $info['img']['host'] . '/' . $info['img']['dir'] . $info['img']['filepath'] . $info['img']['filename'];
$url = $info['protocol'] . $info['host'] . $info['dir'] . $info['file_name'] . '.' . $info['type'];
$addInfo = array('vid' => $info['id'], 'img' => $img, 'url' => $url, 'type' => 2, 'a' => 'addVideo');
$video = $this->status->localData($addInfo);
if (!$video) {
$out = json_encode(array('error' => 1, 'msg' => '上传失败'));
} else {
$out = json_encode($video);
}
}
echo '<script type="text/javascript">parent.video_callback(' . $out . ');</script>';
}
示例14: array
function update_userinfo()
{
$data = array('id' => intval($this->user['user_id']), 'password' => trim($this->input['password']), 'password_again' => trim($this->input['password_again']), 'old_password' => trim($this->input['old_password']));
if (!$data['old_password']) {
//$this->errorOutput("请输入原始密码");
unset($data['old_password']);
}
if (!$data['password']) {
//$this->errorOutput("新密码不可以为空");
unset($data['password']);
unset($data['password_again']);
}
if ($data['old_password'] && !$data['password']) {
$this->errorOutput("新密码不可以为空");
}
if ($data['password'] && $data['password'] != $data['password_again']) {
$this->errorOutput('两次输入的密码不一样');
}
$curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir']);
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addRequestData('a', 'update_password');
foreach ($data as $key => $val) {
$curl->addRequestData($key, $val);
}
if ($_FILES['Filedata']) {
$curl->addFile($_FILES);
}
$return = $curl->request('member.php');
if ($return && $return[0]) {
if ($return[0]['error'] == -1) {
$this->errorOutput('原始密码错误');
}
}
$this->addLogs('更新用户资料', null, null, $this->user['user_name']);
$this->addItem($return[0]);
$this->output();
}
示例15: foreach
function get_video_id($file)
{
foreach ($file['Filedata'] as $k => $v) {
$video['videofile'][$k] = $file['Filedata'][$k];
}
$curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
$curl->setSubmitType('post');
$curl->setReturnFormat('json');
$curl->initPostData();
$curl->addFile($video);
$curl->addRequestData('vod_leixing', 1);
$ret = $curl->request('create.php');
return $ret[0];
}