当前位置: 首页>>代码示例>>PHP>>正文


PHP Uploader::upload方法代码示例

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


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

示例1: upload

 /**
  * Upload image to cloudinary and return the shortened url
  * @param  Image $image 
  * @return string        shortened url
  */
 public function upload($image)
 {
     $this->intConfig();
     if (!is_null($image)) {
         $result = $this->uploader->upload($image);
         $longUrl = $result['url'];
         $this->publicId = $result['public_id'];
         $this->shortUrl = $this->shortenUrl($longUrl);
     }
 }
开发者ID:bendozy,项目名称:YouTooMuch,代码行数:15,代码来源:UploadImage.php

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: upload

 public function upload($file, $options = array())
 {
     $options['return_error'] = false;
     $ret = Uploader::upload($file, $options);
     $preloaded = new PreloadedFile(Cloudinary::signedPreloadedImage($ret));
     if ($this->verifyUpload && !$preloaded . is_valid()) {
         throw new \Exception("Error! Couldn't verify cloudinary response!");
     }
     $this->identifier = $preloaded->extendedIdentifier();
 }
开发者ID:engineor,项目名称:cloudinary_php,代码行数:10,代码来源:CloudinaryField.php

示例7: upload

 /**
  * Attempt to upload a file via remote import, file system import or standard upload.
  *
  * @access public
  * @param string|array $file
  * @param array $attachment
  * @param array $options
  * @return array
  */
 public function upload($file, $attachment, $options)
 {
     if ($attachment['importFrom']) {
         if (preg_match('/(http|https)/', $attachment['importFrom'])) {
             return $this->uploader->importRemote($attachment['importFrom'], $options);
         } else {
             return $this->uploader->import($attachment['importFrom'], $options);
         }
     }
     return $this->uploader->upload($file, $options);
 }
开发者ID:mathg,项目名称:skinsound,代码行数:20,代码来源:AttachmentBehavior.php

示例8: actionIndex

 public function actionIndex()
 {
     $userId = self::checkAdmin();
     $albums = Category::getCategoryGallery();
     $category = Category::getAdminCategory();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (isset($_POST['data'])) {
             $_SESSION['id_cat'] = $_POST['data'];
         }
         $uploader = new Uploader();
         $data = $uploader->upload($_FILES['file'], array('limit' => 5, 'maxSize' => 10, 'extensions' => null, 'required' => false, 'uploadDir' => 'template/gallery/large/', 'title' => array('name'), 'removeFiles' => true, 'perms' => null, 'onCheck' => null, 'onError' => null, 'onSuccess' => null, 'onUpload' => null, 'onComplete' => null, 'onRemove' => 'onFilesRemoveCallback'));
         $img = new resizeImg('template/gallery/large/' . $_FILES['file']['name']);
         $img->resize(150, 150, 'crop');
         $img->save($_FILES['file']['name']);
         Gallery::saveImgToDB($_FILES['file']['name'], $_SESSION['id_cat']);
     }
     $this->render('admin\\adminUpload', ['title' => 'Загрузка изображений', 'albums' => $albums, 'user' => $userId['email']]);
     return true;
 }
开发者ID:bugaydima,项目名称:photogallery,代码行数:19,代码来源:AdminUploadController.php

示例9: array

	List extend
*/
Route::get('admin/extend', array('before' => 'auth', 'main' => function ($page = 1) {
    $vars['messages'] = Notify::read();
    $vars['token'] = Csrf::token();
    return View::create('extend/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
}));
Route::post('admin/get_fields', array('before' => 'auth', 'main' => function () {
    $input = Input::get(array('id', 'pagetype'));
    // get the extended fields
    $vars['fields'] = Extend::fields('page', -1, $input['pagetype']);
    $html = View::create('pages/fields', $vars)->render();
    $token = '<input name="token" type="hidden" value="' . Csrf::token() . '">';
    return Response::json(array('token' => $token, 'html' => $html));
}));
/*
	Upload an image
*/
Route::post('admin/upload', array('before' => 'auth', 'main' => function () {
    $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
    $filepath = $uploader->upload($_FILES['file']);
    $uri = Config::app('url', '/') . 'content/' . basename($filepath);
    $output = array('uri' => $uri);
    return Response::json($output);
}));
/*
	404 error
*/
Route::error('404', function () {
    return Response::error(404);
});
开发者ID:pepfi,项目名称:anchor-cms,代码行数:31,代码来源:admin.php

示例10: upload

 public static function upload($file)
 {
     $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
     $filepath = $uploader->upload($file);
     return $filepath;
 }
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:6,代码来源:extend.php

示例11: array

     break;
     /* 上传图片 */
 /* 上传图片 */
 case 'uploadimage':
     /* 上传涂鸦 */
 /* 上传涂鸦 */
 case 'uploadscrawl':
     /* 上传视频 */
 /* 上传视频 */
 case 'uploadvideo':
     /* 上传文件 */
 /* 上传文件 */
 case 'uploadfile':
     $policy = array('key' => $_CONFIG['imageFieldName'], 'min_size' => 0, 'max_size' => $_CONFIG['imageMaxSize'], 'file_type' => 'image', 'check_image' => false);
     $up = new Uploader(include "config.inc.php");
     $error = $up->upload($policy);
     if ($error) {
         $result = array('state' => $up->errorMessage($error));
     } else {
         $file = $up->getFile();
         $result = array('state' => 'SUCCESS', 'url' => $file['download_url'], 'title' => $file['fileid'], 'original' => $file['name'], 'type' => "", 'size' => $file['size']);
     }
     break;
     /* 列出图片 */
 /* 列出图片 */
 case 'listimage':
     $result = (include "action_list.php");
     break;
     /* 列出文件 */
 /* 列出文件 */
 case 'listfile':
开发者ID:supefun,项目名称:SupeFramework,代码行数:31,代码来源:ueditor.php

示例12: Uploader

<?php

require_once 'upload.class.php';
if (!empty($_FILES)) {
    $uploader = new Uploader();
    $uploader->upload('file_name', '/file_upload/upload.php');
}
开发者ID:phantaidd,项目名称:PHP-curl,代码行数:7,代码来源:curl.php

示例13: Uploader

 * Date: 11/7/15
 * Time: 5:24 PM
 */
include_once 'Connection.php';
include_once 'Uploader.php';
include_once 'RSS.php';
if (isset($_POST['submit'])) {
    $title = filter_input(INPUT_POST, 'title');
    $releaseDate = filter_input(INPUT_POST, 'release_date');
    $directorId = filter_input(INPUT_POST, 'director');
    $actorIds = filter_input(INPUT_POST, 'actors', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
    $synopsis = filter_input(INPUT_POST, 'synopsis');
    $return = filter_input(INPUT_POST, 'return');
    $file = $_FILES['upload'];
    $uploader = new Uploader($file);
    $imageLink = $uploader->upload();
    $connection = new Connection();
    $director = $connection->getPeopleById([$directorId]);
    $actors = $connection->getPeopleById($actorIds);
    $view = new Movie(NULL, $director[0], $title, $releaseDate, $synopsis, NULL, $imageLink, $actors);
    $id = $connection->addMovie($view);
    if (!$return) {
        $return = "../index.php";
    }
    $rss = new RSS($id, $title, $id, $synopsis);
    $rss->newRSS();
    if (strpos($return, "?") !== FALSE) {
        $notificationGets = "&addentity={$title}";
    } else {
        $notificationGets = "?addentity={$title}";
    }
开发者ID:ecs0,项目名称:tbmd.com,代码行数:31,代码来源:movie_handler.php

示例14: Uploader

<?php

require __DIR__ . '/../../autoload.php';
$title = $_POST['name'];
$img = $_FILES['image'];
$description = $_POST['description'];
$id = $_POST['id'];
$uploaddir = __DIR__ . "/../../img";
/*upload img*/
$name_file = 'image';
$img = '/../../img/' . $_FILES['image']['name'];
if (!empty($img) && !empty($title) && !empty($description)) {
    $uploads = new Uploader($name_file);
    $uploads->upload($uploaddir);
    $portfolio = new Portfolio();
    $portfolio->updateById($title, $img, $description, $id);
}
header("Location: ../../admin.php");
开发者ID:Alexandr1987,项目名称:PHP1,代码行数:18,代码来源:PorfolioUpdate.php

示例15: Uploader

<?php

/**
 * Created by PhpStorm.
 * User: Cranky4
 * Date: 13.10.2015
 * Time: 18:04
 */
//стартуем сессию, если ее еще нет
session_start();
include_once "class/Uploader.php";
$uploader = new Uploader();
if ($_FILES && array_key_exists("pic", $_FILES)) {
    $uploader->setMaxSize(2 * 1024 * 1024);
    if ($pathInfo = $uploader->upload($_FILES['pic'])) {
        //сохраняем имя файла в сессию юзера
        $_SESSION['files'][] = $pathInfo['name'];
        //редирект на картинку
        header("Location: /task1/pic.php?path=/uploads/" . $pathInfo['name']);
    } else {
        //вывод ошибок
        print_r($uploader->getErrors());
    }
}
?>

<form method="POST" enctype="multipart/form-data">
    <input type="file" name="pic" required> <input type="submit" value="upload">
</form>

<ul>
开发者ID:Cranky4,项目名称:logg26,代码行数:31,代码来源:index.php


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