本文整理汇总了PHP中Uploader::process方法的典型用法代码示例。如果您正苦于以下问题:PHP Uploader::process方法的具体用法?PHP Uploader::process怎么用?PHP Uploader::process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uploader
的用法示例。
在下文中一共展示了Uploader::process方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: crop_by_url
public function crop_by_url($tmpfile, $scale_width, $x, $y, $w, $h)
{
$imagine = new Imagine\Imagick\Imagine();
$image = $imagine->open($tmpfile);
$image->resize(new Imagine\Image\Box($scale_width, 0))->crop(new Imagine\Image\Point($x, $y), new Imagine\Image\Box($w, $h))->save($tmpfile);
$uploader = new Uploader();
$uploader->process($tmpfile);
return $uploader;
}
示例2: processImportTheme
public function processImportTheme()
{
$this->display = 'importtheme';
if ($this->context->mode == Context::MODE_HOST) {
return true;
}
if (isset($_FILES['themearchive']) && isset($_POST['filename']) && Tools::isSubmit('theme_archive_server')) {
$uniqid = uniqid();
$sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR;
mkdir($sandbox);
$archive_uploaded = false;
if (Tools::getValue('filename') != '') {
$uploader = new Uploader('themearchive');
$uploader->setAcceptTypes(array('zip'));
$uploader->setSavePath($sandbox);
$file = $uploader->process(Theme::UPLOADED_THEME_DIR_NAME . '.zip');
if ($file[0]['error'] === 0) {
if (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$archive_uploaded = true;
} else {
$this->errors[] = $this->l('Zip file seems to be broken');
}
} else {
$this->errors[] = $file[0]['error'];
}
} elseif (Tools::getValue('themearchiveUrl') != '') {
if (!Validate::isModuleUrl($url = Tools::getValue('themearchiveUrl'), $this->errors)) {
$this->errors[] = $this->l('Only zip files are allowed');
} elseif (!Tools::copy($url, $sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$this->errors[] = $this->l('Error during the file download');
} elseif (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$archive_uploaded = true;
} else {
$this->errors[] = $this->l('Zip file seems to be broken');
}
} elseif (Tools::getValue('theme_archive_server') != '') {
$filename = _PS_ALL_THEMES_DIR_ . Tools::getValue('theme_archive_server');
if (substr($filename, -4) != '.zip') {
$this->errors[] = $this->l('Only zip files are allowed');
} elseif (!copy($filename, $sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$this->errors[] = $this->l('An error has occurred during the file copy.');
} elseif (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$archive_uploaded = true;
} else {
$this->errors[] = $this->l('Zip file seems to be broken');
}
} else {
$this->errors[] = $this->l('You must upload or enter a location of your zip');
}
if ($archive_uploaded) {
if ($this->extractTheme($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip', $sandbox)) {
$this->installTheme(Theme::UPLOADED_THEME_DIR_NAME, $sandbox);
}
}
Tools::deleteDirectory($sandbox);
if (count($this->errors) > 0) {
$this->display = 'importtheme';
} else {
Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes') . '&conf=18');
}
}
}
示例3:
<?php
/*
* Aikar's Minecraft Timings Parser
*
* Written by Aikar <aikar@aikar.co>
* http://aikar.co
* http://starlis.com
*
* @license MIT
*/
namespace Starlis\Timings;
require "init.php";
Uploader::process();
示例4: bp_upload
/**
*
* 分段上传接口
* 第一步:
* POST bp_upload.json
* {
* "md5":"文件md5",
* "size":"文件大小",
* "basedir":"文件夹路径",
* "type":"文件解析类型 0文件,1音频,4视频",
* "filename":"文件名"
* }
*
* 第二部:
* GET bp_upload.json?upload_id={临时上传id}&offset={碎片偏移量}&length={分段大小}
* FILES
*/
public function bp_upload()
{
$upload_id = isset($_GET['upload_id']) ? $_GET['upload_id'] : 0;
if (!$upload_id) {
//创建临时文件
$data = $this->get_data();
if (isset($data['md5']) && isset($data['size'])) {
} else {
$this->response(ResponseType::ERROR_LACKPARAMS);
}
if ($data['size'] > Core::config('file_max_size')) {
$this->response(ResponseType::FILE_ERROR_SIZELIMIT);
}
//存放路径是否存在
$basedir = $data['basedir'];
if (!$basedir) {
$basedir = '/home';
}
$basedirModel = new Models\FileDirectory();
if (!$basedirModel->findOne($basedir)) {
$this->response(ResponseType::FILE_ERROR_DIR_INVALID);
}
$tempModel = new Models\Temp($this->user_id);
$tempModel->md5 = strtolower($data['md5']);
$tempModel->size = intval($data['size']);
$tempModel->type = intval($data['type']);
$tempModel->cid = intval($data['category']);
$tempModel->basedir = $basedir;
if (!$data['filename']) {
$tempModel->filename = sprintf('%.0f', microtime(TRUE) * 1000);
} else {
$tempModel->filename = $data['filename'];
}
if ($tempModel->create()) {
$result['upload_id'] = $tempModel->get_upload_id();
$result['offset'] = 0;
$result['uploaded'] = FALSE;
$this->response(ResponseType::PHOTO_BPUPLOAD_OK_CREATETEMP, '', $result);
}
$this->response(ResponseType::PHOTO_BPUPLOAD_ERROR_CREATETEMP);
} else {
//上传第二步
$offset = isset($_GET['offset']) ? intval($_GET['offset']) : NULL;
$length = isset($_GET['length']) ? intval($_GET['length']) : NULL;
/*
if(isset($_GET['offset'])) {
$offset=intval($_GET['offset']);
}else{
$this->response(ResponseType::ERROR_LACKPARAMS);
}
*/
$tempModel = new Models\Temp($this->user_id);
if (!$tempModel->getTemp($upload_id)) {
$this->response(ResponseType::PHOTO_BPUPLOAD_ERROR_NOTEMP);
}
//追加文件碎片
if ($tempModel->tmp_source->length < $tempModel->size) {
if ($_FILES) {
foreach ($_FILES as $upfile) {
$in_path = $upfile['tmp_name'];
}
} else {
$in_path = 'php://input';
}
$tempModel->append($in_path, $offset, $length);
}
//验证临时文件完整性
$finish = FALSE;
if ($tempModel->tmp_source->length >= $tempModel->size) {
if ($tempModel->md5 && $tempModel->md5 == $tempModel->tmp_source->md5) {
$finish = TRUE;
} else {
$tempModel->destroy();
$this->response(ResponseType::PHOTO_BPUPLOAD_ERROR_DAMAGETEMP);
}
}
if ($finish) {
$tmp_file = $tempModel->tmp_source->downBuffer();
//临时文件是否可访问
if ($tmp_file) {
$uploader = new Uploader();
$uploader->process($tmp_file, '', $tempModel->size, $tempModel->md5);
} else {
//.........这里部分代码省略.........
示例5: getThumbInstance
public function getThumbInstance()
{
if ($this->getType() == self::FILETYPE_VIDEO) {
require_once FS_ROOT . 'include/ffmpeg/FFmpegAutoloader.php';
$ffmpegOutput = new FFmpegOutputProvider(Core::config('ffmpeg_binary'));
$ffmpeMovie = new FFmpegMovie($this->tmpfile, $ffmpegOutput, Core::config('ffmpeg_binary'));
// $duration = $ffmpeMovie->getDuration();
// $ffmpegFrame = $ffmpeMovie->getFrameAtTime($duration/2);
$ffmpegFrame = $ffmpeMovie->getFrame();
if ($ffmpegFrame) {
$im = $ffmpegFrame->toGDImage();
$tn_tmp = Core::tempname();
imagejpeg($im, $tn_tmp);
imagedestroy($im);
$tnUploader = new Uploader();
$tnUploader->process($tn_tmp);
return $tnUploader;
}
return NULL;
}
}
示例6: update_avatar
/**
*
* 更新头像接口
* POST update_avatar.json
* {
* "pid":"原始照片的id",
* "middle_content":"大头像base64数据"
* "original_content":"原图base64数据"
* }
*/
public function update_avatar()
{
if ($_POST['data']) {
//flash截取头像
$data = json_decode($_POST['data'], TRUE);
} else {
$data = $this->get_data();
//手机端
}
//如果是j2me平台直接取原图
if ($this->get_source() == 6) {
$middle_data = @base64_decode($data['original_content']);
} else {
$middle_data = @base64_decode($data['middle_content']);
}
$pid = $data['pid'];
//原图PID
$original_data = @base64_decode($data['original_content']);
//原图数据
if ($pid) {
$photoModel = new Models\Photo();
if (!$photoModel->findOne($pid)) {
$this->response(ResponseType::PHOTO_UPAVATAR_ERROR_INVALID);
}
}
if (!$pid && $original_data) {
$tmporigin = Core::tempname();
file_put_contents($tmporigin, $original_data);
$uploader = new Uploader();
$uploader->process($tmporigin);
//不是图片类型
if ($uploader->getType() !== Uploader::FILETYPE_IMAGE) {
$this->response(ResponseType::PHOTO_ERROR_IMAGETYPE);
}
if ($result = $this->_processUpload($uploader, 1)) {
$pid = $result['id'];
} else {
$this->response(ResponseType::PHOTO_UPAVATAR_ERROR_INVALID);
}
}
if (!$pid || !$middle_data) {
$this->response(ResponseType::ERROR_LACKPARAMS);
}
$tmpfile = Core::tempname();
if (!file_put_contents($tmpfile, $middle_data)) {
$this->response(ResponseType::PHOTO_UPAVATAR_ERROR);
}
$uploader = new Uploader();
$uploader->process($tmpfile);
//不是图片类型
if ($uploader->getType() !== Uploader::FILETYPE_IMAGE) {
$this->response(ResponseType::PHOTO_ERROR_IMAGETYPE);
}
$photoModel = new Models\Photo();
$updata['cid'] = 1;
//我的头像相册
$updata['oid'] = $pid;
$updata['ctrl_type'] = 1;
$updata['is_animated'] = 0;
$updata['mtime'] = time();
if ($photoModel->create($uploader, $updata)) {
$result['id'] = $photoModel->get_pid();
$result['md5'] = $photoModel->md5;
$imgurls = $photoModel->geturi($result['id'], 48);
$result['src'] = $imgurls[0];
list($set_avatar, $first_time) = $photoModel->setAvatar($photoModel->get_pid(), $updata['oid'], $updata['mtime']);
if (!$set_avatar) {
$this->response(ResponseType::PHOTO_UPAVATAR_ERROR);
}
$user_model = User_Model::instance();
$member_field = array('updatetime' => time());
if ($first_time) {
$sms_content = '您好,这是您第一次设置头像,系统赠送了100条短信给您';
$user_model->present_sms($this->getUid(), 100, $sms_content, FALSE);
$user_info = $user_model->get_user_info($this->getUid());
$member_field['completed'] = $user_info['completed'] + 10;
}
//发送头像修改动态
$feedModel = new Feed_Model();
$accessory[] = array('id' => $result['id']);
$feedModel->addFeed($this->user_id, 3, '更新头像', $this->get_source(), array(), array(), $accessory);
//更新memberinfo表
$user_model->update_user_info($this->getUid(), $member_field);
$this->response(ResponseType::PHOTO_UPAVATAR_OK, '', $result);
unlink($tmpfile);
} else {
$this->response(ResponseType::PHOTO_UPAVATAR_ERROR);
}
}