• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Uploader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Uploader的典型用法代码示例。如果您正苦于以下问题:PHP Uploader类的具体用法?PHP Uploader怎么用?PHP Uploader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Uploader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: changeAvatar

 function changeAvatar()
 {
     if (isset($_POST['avasubmit'])) {
         $upload_dir = './images/avatars/';
         $cfile = md5($_SESSION['nickname']);
         $u = new Uploader();
         try {
             if (is_file($upload_dir . $cfile . '.jpg')) {
                 unlink($upload_dir . $cfile . '.jpg');
             }
             if (is_file($upload_dir . $cfile . '.jpeg')) {
                 unlink($upload_dir . $cfile . '.jpeg');
             }
             if (is_file($upload_dir . $cfile . '.png')) {
                 unlink($upload_dir . $cfile . '.png');
             }
             if (is_file($upload_dir . $cfile . '.gif')) {
                 unlink($upload_dir . $cfile . '.gif');
             }
             $cfile = $u->Upload('avach', $upload_dir, $cfile);
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
         $sql = "UPDATE useravatar SET avatar='" . $cfile . "' WHERE id=(SELECT avatar_id FROM users WHERE id=" . $_SESSION['id'] . ");";
         $this->db->query($sql);
         $_SESSION['avatar'] = $cfile;
     }
 }
开发者ID:dicksel,项目名称:ShitPress,代码行数:28,代码来源:personal.php


示例2: fileUploadBlock

    public static function fileUploadBlock()
    {
        if (self::$invalid) {
            return;
        }
        i18n::set('admin');
        $uploader = new Uploader('editFiles', 'EditPage::handleUpload', false, array('multi' => true));
        queue_js_string("/*\$(function(){\$('.view-uploads').overlay({\n\tmask: {\n\t\tcolor: '#000',\n\t\tloadSpeed: 200,\n\t\topacity: 0.7\n\t},\n\n\tcloseOnClick: true\n});});*/");
        $uploadedButton = sprintf("<a href='#' class='action view-uploads' rel='#cc_uploaded_overlay'>%s%s</a>", icon('folder_picture'), __('admin', 'view-all-files'));
        $uploadedFiles = <<<EOT
<div class="cc_uploaded_files">
{$uploadedButton}
\t<div id="cc_uploaded_overlay" class="cc_modal">
\t\t<h2>%s</h2>
\t\t<ul class="cc_file_list">
\t\t\t%s
\t\t</ul>
\t</div>
</div>
EOT;
        //foreach(Uploads::getAllFiles() as $)
        $r .= sprintf("<h3>%s</h3>%s%s", __('upload-files'), sprintf($uploadedFiles, __('uploaded-files'), $files), $uploader->createHTML());
        i18n::restore();
        return $r;
    }
开发者ID:alecgorge,项目名称:TopHat,代码行数:25,代码来源:edit-page.php


示例3: upload

 public function upload()
 {
     //检查登录
     $this->_login();
     //单文件
     if (!$_FILES || $_FILES["file"]["error"] > 0) {
         echo '图片不能为空!';
         throw new Exception('exit');
     }
     //处理上传的图片
     $dir = 'goods/';
     $upload = new Uploader($_FILES, $dir);
     //保存图片
     if ($upload->save()) {
         $data['goods_photo'] = $upload->getUrl();
         //图片路径
     }
     $da = array();
     $da = $this->_getPost();
     $data_new = array_merge($data, $da);
     AdminGoodsM::add($data_new);
     //跳转到未出售商品列表
     $url = url('admin', 'admingoods::unsale');
     header('Location:' . $url);
     throw new Exception('exit');
 }
开发者ID:lughong,项目名称:shop,代码行数:26,代码来源:admingoods.php


示例4: save

 function save($package)
 {
     $Filter = new Filter();
     $name = $this->getName($Filter->get($package, 'name', null));
     if ($Filter->get($package, 'error', false)) {
         // An HTTP error occurred
         return false;
     } else {
         if (empty($name)) {
             // An empty file name was posted
             return false;
         } else {
             if ($this->exists($name)) {
                 return false;
             }
         }
     }
     $Uploader = new Uploader(array("application/zip"), array(SB_TMP_DIR));
     list($result, $tmpfile) = $Uploader->upload($package, SB_TMP_DIR);
     if (intval($result) != 1) {
         // The file was not uploaded
         return false;
     }
     if ($this->unzip($tmpfile, $this->directory)) {
         return true;
     }
     unlink($tmpfile);
     return false;
 }
开发者ID:schulzp,项目名称:stamm_leo_website,代码行数:29,代码来源:module.php


示例5: save

 function save($package)
 {
     $Filter = new Filter();
     $name = $this->getName($Filter->get($package, 'name', null));
     if ($Filter->get($package, 'error', false)) {
         // An HTTP error occurred
         return false;
     } else {
         if (empty($name)) {
             // An empty file name was posted
             return false;
         } else {
             if ($this->exists($name)) {
                 return false;
             }
         }
     }
     $Uploader = new Uploader(array("application/zip"), array(SB_TMP_DIR));
     list($result, $tmpfile) = $Uploader->upload($package, SB_TMP_DIR);
     if (intval($result) != 1) {
         // The file was not uploaded
         return false;
     }
     // handle the file move to the managers dir
     if (!FileSystem::make_dir($this->directory . $name)) {
         // The target directory could not be created
         return false;
     }
     return $this->unzip($tmpfile, $this->directory . $name);
 }
开发者ID:schulzp,项目名称:stamm_leo_website,代码行数:30,代码来源:fragment.php


示例6: testUpload

 public function testUpload()
 {
     $connection = new Connection('http://localhost:5984');
     $uploader = new Uploader($connection);
     $rf = new ResponseFactory();
     $get = new GetDocument($rf);
     $doc = $get->getDocument($connection, 'test', 'doc');
     $uploader->upload('PUT', 'test/' . $doc->_id . '/keya?rev=' . $doc->_rev, 'key');
 }
开发者ID:chemisus,项目名称:snuggie,代码行数:9,代码来源:UploaderTest.php


示例7: uploadImage

 function uploadImage()
 {
     $uploader = new \Uploader();
     $from = isset($_GET["from"]) ? $_GET["from"] : "default";
     $filename = $_GET["filename"];
     $info = $uploader->uploadAndPersistImage($filename, "php://input", $from);
     header('Content-Type: application/json');
     exit(json_encode($info));
 }
开发者ID:sks40gb,项目名称:jnv,代码行数:9,代码来源:UploaderAction.php


示例8: createAttachment

 public function createAttachment(Uploader $uploader, $database, $id, $revision, $name, $file)
 {
     $value = $uploader->upload('PUT', $database . '/' . $id . '/' . $name . '?rev=' . $revision, $file);
     $response = $this->response_factory->make($value);
     if ($response->status() !== '201' && $response->status() !== '202') {
         throw new AttachmentCreationException();
     }
     return json_decode($response->body());
 }
开发者ID:chemisus,项目名称:snuggie,代码行数:9,代码来源:CreateAttachment.php


示例9: uploadfile

 function uploadfile($para)
 {
     import('image.func');
     import('uploader.lib');
     $uploader = new Uploader();
     $uploader->allowed_type(IMAGE_FILE_TYPE);
     $uploader->allowed_size(2097152);
     // 2M
     $files = $para;
     //$_FILES['activity_banner'];
     if ($files['error'] == UPLOAD_ERR_OK) {
         /* 处理文件上传 */
         $file = array('name' => $files['name'], 'type' => $files['type'], 'tmp_name' => $files['tmp_name'], 'size' => $files['size'], 'error' => $files['error']);
         $uploader->addFile($file);
         if (!$uploader->file_info()) {
             $data = current($uploader->get_error());
             $res = Lang::get($data['msg']);
             $this->view_iframe();
             echo "<script type='text/javascript'>alert('{$res}');</script>";
             return false;
         }
         $uploader->root_dir(ROOT_PATH);
         $dirname = 'data/files/mall/weixin';
         $filename = $uploader->random_filename();
         $file_path = $uploader->save($dirname, $filename);
     }
     return $file_path;
 }
开发者ID:184609680,项目名称:wcy_O2O_95180,代码行数:28,代码来源:weixin.lib.php


示例10: upload

function upload()
{
    include_once "classes/Uploader.class.php";
    $uploader = new Uploader("image-data");
    $uploader->saveIn("img");
    $fileUploaded = $uploader->save();
    if ($fileUploaded) {
        $out = "new file uploaded";
    } else {
        $out = "something went wrong";
    }
    return $out;
}
开发者ID:smithnikki,项目名称:sites,代码行数:13,代码来源:upload.php


示例11: run

 public function run()
 {
     $uploader = new Uploader();
     if (Yii::app()->request->isPostRequest) {
         //普通上传
         $uploader->initSimple('album')->uploadSimple('simple_file');
         $error = $uploader->getError();
         if (!$error) {
             $data = array('file_name' => $uploader->file_name, 'file_path' => $uploader->file_path, 'file_path_full' => Helper::getFullUrl($uploader->file_path), 'thumb_path' => $uploader->thumb_path, 'thumb_path_full' => Helper::getFullUrl($uploader->thumb_path), 'file_ext' => $uploader->file_ext);
             App::response(200, 'success', $data);
         } else {
             App::response(101, $error);
         }
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:15,代码来源:UploadSimpleAction.php


示例12: actionUpload

 /**
  * 文件上传
  */
 public function actionUpload()
 {
     $uploader = new Uploader();
     if (Yii::app()->request->isPostRequest) {
         //断点上传
         $uploader->initSimple('kindeditor')->uploadSimple('kindeditor_file');
         $error = $uploader->getError();
         if (!$error) {
             //返回kindeditor接收的json格式
             exit(CJSON::encode(array('error' => 0, 'url' => Helper::getFullUrl($uploader->file_path))));
         } else {
             exit(CJSON::encode(array('error' => 0, 'message' => $error)));
         }
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:18,代码来源:KindeditorController.php


示例13: init

 /**
  * 初始化函数,并返回当前类
  * @return Uploader
  */
 public static function init()
 {
     if (!self::$selfObject) {
         self::$selfObject = new Uploader();
     }
     return self::$selfObject;
 }
开发者ID:cumtCsdn,项目名称:cumtxa,代码行数:11,代码来源:Uploader.class.php


示例14: actionBatch

 /**
  * 批量操作
  * @throws CHttpException
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($this->_request->getParam('command'));
         $ids = intval($this->_request->getParam('id'));
     } elseif ($this->method() == 'POST') {
         $command = $this->_request->getPost('command');
         $ids = $this->_request->getPost('id');
     } else {
         throw new CHttpException(404, Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'attachDelete':
             foreach ((array) $ids as $id) {
                 $uploadModel = Upload::model()->findByPk($id);
                 if ($uploadModel) {
                     Uploader::deleteFile($uploadModel->file_name);
                     $uploadModel->delete();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index'));
 }
开发者ID:github-zjh,项目名称:task,代码行数:32,代码来源:AttachController.php


示例15: uploadImage

 public static function uploadImage()
 {
     $allowFile = array("image/jpeg", "image/png", "image/gif");
     $df = "Ymd-H-i-s";
     $fileName = "TMPIMG" . date($df) . "." . Uploader::getExtension();
     if (!Uploader::getTempFile()) {
         $result['error'] = true;
         $result['message'] = 'Please browse for a file!';
         echo json_encode($result);
         return;
     }
     if (!in_array(Uploader::getType(), $allowFile)) {
         $result['error'] = true;
         $result['message'] = 'Please choose only image file (jpg, png or gif)!';
         echo json_encode($result);
         return;
     }
     if (Uploader::moveUploadFileTo(self::$tmpDir, $fileName)) {
         $result['error'] = false;
         $result['message'] = 'File upload succeeded!';
         $result['image'] = 'assets/upload/tmp/' . $fileName;
         $result['alt'] = $fileName;
     } else {
         $result['error'] = true;
         $result['message'] = 'Fail in moving file upload!';
     }
     echo json_encode($result);
 }
开发者ID:midmike,项目名称:h0001pre,代码行数:28,代码来源:FoodControl.php


示例16: run

 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             foreach ((array) $ids as $id) {
                 $softModel = Soft::model()->findByPk($id);
                 if ($softModel) {
                     Uploader::deleteFile(ROOT_PATH . $softModel->soft_icon);
                     Uploader::deleteFile(ROOT_PATH . $softModel->soft_file);
                 }
             }
             Soft::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             Soft::model()->updateAll(['status' => 'Y'], $criteria);
             break;
         case 'hidden':
             //隐藏
             Soft::model()->updateAll(['status' => 'N'], $criteria);
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:35,代码来源:BatchAction.php


示例17: upload

function upload()
{
    include_once 'models/Uploader.php';
    $uploader = new Uploader('image_data');
    $uploader->saveIn('img');
    $fileUploaded = $uploader->save();
    if ($fileUploaded) {
        $out = 'new file uploaded';
    } else {
        $out = 'something went wrong';
    }
    $out .= "<pre>";
    $out .= print_r($_FILES, true);
    $out .= "</pre>";
    return $out;
}
开发者ID:arvin-tcm,项目名称:CS526_Web,代码行数:16,代码来源:add.php


示例18: setMaxFileSize

 public function setMaxFileSize($new_size)
 {
     if ($new_size > 0 and $new_size <= Uploader::uploadLimit()) {
         $this->max_file_size = $new_size;
     } else {
         throw new Exception('Invalid file size set');
     }
 }
开发者ID:Michaeldgeek,项目名称:NacossUnn,代码行数:8,代码来源:class.uploader.php


示例19: run

 public function run()
 {
     $uploader = new Uploader();
     if (Yii::app()->request->isPostRequest) {
         //开始剪切
         $image = $_POST['file'];
         $uploader->initSimple('avatar');
         $cut_image = $uploader->imageCut($image, array('cut_w' => 100, 'cut_h' => 100, 'pos_x' => $_POST['x'], 'pos_y' => $_POST['y']));
         $error = $uploader->getError();
         if (!$error) {
             $data = array('cut_avatar' => $cut_image);
             App::response(200, '裁剪成功', $data);
         } else {
             App::response(101, $error);
         }
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:17,代码来源:AvatarCutAction.php


示例20: do_handle

 public function do_handle()
 {
     /* 抓取远程图片 */
     $list = array();
     if (isset($_POST[$this->fieldName])) {
         $source = $_POST[$this->fieldName];
     } else {
         $source = $_GET[$this->fieldName];
     }
     foreach ($source as $imgUrl) {
         $item = new Uploader($imgUrl, $this->config, "remote");
         $info = $item->getFileInfo();
         array_push($list, array("state" => $info["state"], "url" => $info["url"], "size" => $info["size"], "title" => htmlspecialchars($info["title"]), "original" => htmlspecialchars($info["original"]), "source" => htmlspecialchars($imgUrl)));
     }
     /* 返回抓取数据 */
     return json_encode(array('state' => count($list) ? 'SUCCESS' : 'ERROR', 'list' => $list));
 }
开发者ID:AlusaChen,项目名称:test-lar,代码行数:17,代码来源:Crawler.php



注:本文中的Uploader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Uri类代码示例发布时间:2022-05-23
下一篇:
PHP UploadedFile类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap