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

PHP UploadHandler类代码示例

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

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



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

示例1: upload

 public function upload()
 {
     $this->load->library('replay');
     error_reporting(E_ALL | E_STRICT);
     $this->load->helper("upload.class");
     $upload_handler = new UploadHandler();
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
     header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'OPTIONS':
             break;
         case 'HEAD':
         case 'GET':
             $upload_handler->get();
             break;
         case 'POST':
             if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
                 $upload_handler->delete();
             } else {
                 $upload_handler->post();
             }
             break;
         case 'DELETE':
             $upload_handler->delete();
             break;
         default:
             header('HTTP/1.1 405 Method Not Allowed');
     }
 }
开发者ID:rabbitXIII,项目名称:FFAReplays,代码行数:34,代码来源:uploader.php


示例2: handle

 public function handle()
 {
     // required upload handler helper
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'uploadhandler.php';
     $userId = JFactory::getUser()->id;
     $session = JFactory::getSession();
     $sessionId = $session->getId();
     // make dir
     $tmpImagesDir = JPATH_ROOT . DS . 'tmp' . DS . $userId . DS . $sessionId . DS;
     $tmpUrl = 'tmp/' . $userId . '/' . $sessionId . '/';
     // unlink before create
     @unlink($tmpImagesDir);
     // create folder
     @mkdir($tmpImagesDir, 0777, true);
     $uploadOptions = array('upload_dir' => $tmpImagesDir, 'upload_url' => $tmpUrl, 'script_url' => JRoute::_('index.php?option=com_ntrip&task=uploadfile.handle', false));
     $uploadHandler = new UploadHandler($uploadOptions, false);
     //	$session->set('files', null);
     $files = $session->get('files', array());
     if ($session->get('request_method') == 'delete') {
         $fileDelete = $uploadHandler->delete(false);
         // search file
         $key = array_search($fileDelete, $files);
         // unset in $files
         unset($files[$key]);
         $session->set('files', $files);
         $session->set('request_method', null);
         exit;
     }
     if ($_POST) {
         $file = $uploadHandler->post();
         $files[] = $file;
         $session->set('files', $files);
     }
     exit;
 }
开发者ID:ngxuanmui,项目名称:hp3,代码行数:35,代码来源:uploadfile.php


示例3: upload

 public function upload($config = 'default')
 {
     if (!$this->request->is(array('post', 'put', 'delete'))) {
         die('Method not allowed');
     }
     App::import('Vendor', 'BlueUpload.UploadHandler', array('file' => 'UploadHandler.php'));
     $options = Configure::read("BlueUpload.options.{$config}");
     $upload_handler = new UploadHandler($options, $initialize = false);
     if ($this->request->is(array('post', 'put'))) {
         $content = $upload_handler->post($print_response = false);
         // save into uploads table
         foreach ($content['files'] as &$file) {
             if (!isset($file->error)) {
                 $upload = array('name' => $file->name, 'size' => $file->size, 'type' => $file->type, 'url' => $file->url, 'dir' => $options['upload_dir'], 'deleteUrl' => $file->deleteUrl, 'deleteType' => $file->deleteType);
                 // 'thumbnailUrl' => $file->thumbnailUrl,
                 // 'previewUrl'   => $file->previewUrl,
                 //  ... etc
                 if (isset($options['image_versions'])) {
                     foreach ($options['image_versions'] as $version_name => $version) {
                         if (!empty($version_name)) {
                             $upload[$version_name . 'Url'] = $file->{$version_name . 'Url'};
                         }
                     }
                 }
                 // invoke a custom event so app can mangle the data
                 $event = new CakeEvent('Model.BlueUpload.beforeSave', $this, array('upload' => $upload));
                 $this->Upload->getEventManager()->dispatch($event);
                 if ($event->isStopped()) {
                     continue;
                 }
                 // pickup mangled data
                 if (!empty($event->result['upload'])) {
                     $upload = $event->result['upload'];
                 }
                 $this->Upload->create();
                 $this->Upload->save($upload);
                 $file->id = $this->Upload->getLastInsertID();
                 unset($file->deleteUrl);
                 unset($file->deleteType);
                 // account for apps installed in subdir of webroot
                 $file->url = Router::url($file->url);
                 if (isset($file->thumbnailUrl)) {
                     $file->thumbnailUrl = Router::url($file->thumbnailUrl);
                 }
             }
         }
     } else {
         if ($this->request->is(array('delete'))) {
             $content = $upload_handler->delete($print_response = false);
             // delete from uploads table
             foreach ($content['files'] as &$file) {
             }
         }
     }
     $json = json_encode($content);
     $upload_handler->head();
     echo $json;
     $this->autoRender = false;
 }
开发者ID:ptica,项目名称:BlueUpload,代码行数:59,代码来源:BlueUploadController.php


示例4: handleSave

 public function handleSave()
 {
     require_once __DIR__ . "/../../vendor/fineuploader/Uploader/handler.php";
     $uploader = new \UploadHandler();
     $uploader->allowedExtensions = array("jpeg", "jpg", "png", "gif");
     $result = $uploader->handleUpload(__DIR__ . '/../../www/images/uploaded');
     $this->sendResponse(new \Nette\Application\Responses\JsonResponse($result));
 }
开发者ID:bombush,项目名称:NatsuCon,代码行数:8,代码来源:ManagementPresenter.php


示例5: upload

 public function upload($options = null)
 {
     if (!isset($options['print_response'])) {
         $options['print_response'] = false;
     }
     $upload = new \UploadHandler($options);
     return $upload->get_response();
 }
开发者ID:hashmode,项目名称:cakephp-jquery-file-upload,代码行数:8,代码来源:JqueryFileUploadComponent.php


示例6: getLocalFileDetails

function getLocalFileDetails()
{
    // Initializing normal file upload handler
    $upload_handler = new UploadHandler();
    $fileDetails = $upload_handler->post(false);
    $fileDetails["uploadDir"] = $_POST['folderName'];
    return $fileDetails;
}
开发者ID:Oshan07,项目名称:test-project,代码行数:8,代码来源:ProcessFiles.php


示例7: processupload

 public function processupload()
 {
     header('Access-Control-Allow-Origin: *');
     //$this->load->library('uploadhandler');
     $options = array('upload_dir' => './uploads/profile/', 'upload_url' => base_url() . '/uploads/profile/', 'accept_file_types' => '/\\.(gif|jpeg|jpg|png)$/i');
     //$this->load->library('uploadhandler',$options);
     UploadHandler::model($options);
 }
开发者ID:seph-krueger,项目名称:handyman,代码行数:8,代码来源:FileuploadController.php


示例8: init

 public static function init()
 {
     Constants::$host = self::$host;
     Constants::$pass = self::$pass;
     Constants::$user = self::$user;
     Constants::$database = self::$database;
     UploadHandler::$projectFilesPath = ProjectGlobal::$projectFilesPath;
     UploadHandler::$rootFilesPath = "/upload/generated_files/";
 }
开发者ID:awwthentic1234,项目名称:hey,代码行数:9,代码来源:ProjectGlobal.php


示例9: init

 public static function init()
 {
     Compiler::init(array("css" => "min_single", "js" => "min_single", "getServices" => array("except" => Import::getImportPath() . "service.php"), "global" => array("copy" => array(Import::$uber_src_path . "service.php", Import::getImportPath() . "index.php"), "getImages" => true, "code" => array("tmpl" => array("replace" => array("replaceSrc" => false, "\${images}" => Import::$uber_src_path . "/global/images/")))), "compile" => array(array("id" => "min_single", "minify" => true, "copy" => array(), "code" => array("css" => array("singleFile" => true, "path" => "global/css/"), "js" => array("singleFile" => true, "path" => "global/js/"))), array("id" => "min_multi", "minify" => true, "code" => array("css" => array("singleFile" => false, "path" => "global/css/"), "js" => array("singleFile" => false, "path" => "global/js/"))), array("id" => "unmin", "code" => array("css" => array("singleFile" => false, "path" => "global/css/"), "js" => array("singleFile" => false, "path" => "global/js/"))), array("id" => "unmin_raw", "raw" => true))));
     //------------------------------------------------
     GlobalMas::$host = self::$host;
     GlobalMas::$pass = self::$pass;
     GlobalMas::$user = self::$user;
     GlobalMas::$database = self::$database;
     UploadHandler::$projectFilesPath = ProjectGlobal::$projectFilesPath;
     //UploadHandler::$rootFilesPath = "/upload/generated_files/";
     self::$filesLocalPath = $_SERVER['DOCUMENT_ROOT'] . "/" . UploadHandler::$rootFilesPath . self::$projectFilesPath;
     self::$filesPath = GenFun::get_full_url(self::$filesLocalPath);
 }
开发者ID:awwthentic1234,项目名称:hey,代码行数:13,代码来源:ProjectGlobal.php


示例10: error_reporting

/*
 * jQuery File Upload Plugin PHP Example 5.7
 * https://github.com/blueimp/jQuery-File-Upload
 *
 * Copyright 2010, Sebastian Tschan
 * https://blueimp.net
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */
error_reporting(E_ALL | E_STRICT);
require 'upload.class.php';
require_once "../../includes/initialize.php";
global $session;
$group = Group::get_by_id($session->user_group_id);
$upload_handler = new UploadHandler($group, "questions");
header('Pragma: no-cache');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Content-Disposition: inline; filename="files.json"');
header('X-Content-Type-Options: nosniff');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
switch ($_SERVER['REQUEST_METHOD']) {
    case 'OPTIONS':
        break;
    case 'HEAD':
    case 'GET':
        $upload_handler->get();
        break;
    case 'POST':
开发者ID:NemOry,项目名称:BundledFunWebPanel,代码行数:31,代码来源:question_uploader.php


示例11: ajaxUpload

 /**
  *
  * upload files with ajax
  */
 public function ajaxUpload()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         die;
     }
     require_once gatorconf::get('base_path') . "/include/blueimp/server/php/upload.class.php";
     $upload_handler = new UploadHandler();
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
     header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
     $filename = '?';
     if (isset($_FILES['files']['name'])) {
         $filename = $this->filterInput(implode(" ", $_FILES['files']['name']));
         if (in_array($filename, gatorconf::get('restricted_files'))) {
             die;
         }
     }
     gator::writeLog('upload file ' . $filename);
     $upload_handler->post();
     die;
 }
开发者ID:aimtux,项目名称:kiddiefile,代码行数:29,代码来源:file-gator.php


示例12: upload_file

 protected function upload_file($state_info)
 {
     if (isset($this->upload_fields[$state_info->field_name])) {
         if ($this->callback_upload === null) {
             if ($this->callback_before_upload !== null) {
                 $callback_before_upload_response = call_user_func($this->callback_before_upload, $_FILES, $this->upload_fields[$state_info->field_name]);
                 if ($callback_before_upload_response === false) {
                     return false;
                 } elseif (is_string($callback_before_upload_response)) {
                     return $callback_before_upload_response;
                 }
             }
             $upload_info = $this->upload_fields[$state_info->field_name];
             header('Pragma: no-cache');
             header('Cache-Control: private, no-cache');
             header('Content-Disposition: inline; filename="files.json"');
             header('X-Content-Type-Options: nosniff');
             header('Access-Control-Allow-Origin: *');
             header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
             header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
             $allowed_files = $this->config->file_upload_allow_file_types;
             $reg_exp = '';
             if (!empty($upload_info->allowed_file_types)) {
                 $reg_exp = '/(\\.|\\/)(' . $upload_info->allowed_file_types . ')$/i';
             } else {
                 $reg_exp = '/(\\.|\\/)(' . $allowed_files . ')$/i';
             }
             $max_file_size_ui = $this->config->file_upload_max_file_size;
             $max_file_size_bytes = $this->_convert_bytes_ui_to_bytes($max_file_size_ui);
             $options = array('upload_dir' => $upload_info->upload_path . '/', 'param_name' => $this->_unique_field_name($state_info->field_name), 'upload_url' => base_url() . $upload_info->upload_path . '/', 'accept_file_types' => $reg_exp, 'max_file_size' => $max_file_size_bytes);
             $upload_handler = new UploadHandler($options);
             $upload_handler->default_config_path = $this->default_config_path;
             $uploader_response = $upload_handler->post();
             if (is_array($uploader_response)) {
                 foreach ($uploader_response as &$response) {
                     unset($response->delete_url);
                     unset($response->delete_type);
                 }
             }
             if ($this->callback_after_upload !== null) {
                 $callback_after_upload_response = call_user_func($this->callback_after_upload, $uploader_response, $this->upload_fields[$state_info->field_name], $_FILES);
                 if ($callback_after_upload_response === false) {
                     return false;
                 } elseif (is_string($callback_after_upload_response)) {
                     return $callback_after_upload_response;
                 } elseif (is_array($callback_after_upload_response)) {
                     $uploader_response = $callback_after_upload_response;
                 }
             }
             return $uploader_response;
         } else {
             $upload_response = call_user_func($this->callback_upload, $_FILES, $this->upload_fields[$state_info->field_name]);
             if ($upload_response === false) {
                 return false;
             } else {
                 return $upload_response;
             }
         }
     } else {
         return false;
     }
 }
开发者ID:qwords,项目名称:evote,代码行数:62,代码来源:Grocery_CRUD.php


示例13: processRequest

 public function processRequest()
 {
     // Ignore other requests except POST.
     if ($_SERVER['REQUEST_METHOD'] !== 'POST' || empty($_POST[PostFields::packageGuid])) {
         return;
     }
     if (UploadHandler::$_processed) {
         return;
     }
     UploadHandler::$_processed = true;
     if (array_key_exists('HTTP_X_PREPROCESS_REQUIRED', $_SERVER) && $_SERVER['HTTP_X_PREPROCESS_REQUIRED'] == 'true') {
         $files = $this->getRequestFiles($_POST);
     } else {
         $files =& $_FILES;
     }
     $uploadCache = new UploadCache($this->_cacheRoot);
     $uploadSession = new UploadSession($uploadCache, $_POST, $files, $_SERVER);
     if (!empty($this->_allFilesUploadedCallback)) {
         $uploadSession->setAllFilesUploadedCallback($this->_allFilesUploadedCallback);
     }
     if (!empty($this->_fileUploadedCallback)) {
         $uploadSession->setFileUploadedCallback($this->_fileUploadedCallback);
     }
     $uploadSession->processRequest();
     $this->removeExpiredSessions($uploadCache);
     // Flash requires non-empty response
     if (!headers_sent() && array_key_exists('HTTP_USER_AGENT', $_SERVER) && $_SERVER['HTTP_USER_AGENT'] === 'Shockwave Flash') {
         echo '0';
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:30,代码来源:UploadHandler.class.php


示例14: UploadImage

 function UploadImage()
 {
     //$this->GotoLogin();
     $name = $_FILES['Filedata']['name'];
     $id = rand(10, 10000000);
     $rpath = 'images/building/face/' . face_path($id);
     $image_path = __WEB_ROOT . '/' . $rpath;
     $image_name = $id . '_o.jpg';
     $image_file = $rpath . $image_name;
     $image_file_s = $rpath . $id . '_s.jpg';
     $image_file_t = $rpath . $id . '_t.jpg';
     $image_file_p = $rpath . $id . '_p.jpg';
     $pic_field = 'Filedata';
     $UploadHandler = new UploadHandler($_FILES, $image_path, $pic_field, true, false);
     $UploadHandler->setMaxSize(2048);
     $UploadHandler->setNewName($image_name);
     $ret = $UploadHandler->doUpload();
     if (!$ret) {
         $rets = $UploadHandler->getError();
         $ret = $rets ? implode(" ", (array) $rets) : 'image upload is invalid';
         $r = array('error' => $ret, 'code' => -5);
         if ($r['code'] < 0 && $r['error']) {
             $this->_image_error($rets['error']);
         }
     }
     list($image_width, $image_height, $image_type, $image_attr) = getimagesize($image_file);
     if ($image_width >= 120 && $image_height <= 120) {
         resizeimage($image_file, $image_file_s, 120, 0, true);
     }
     if ($image_height >= 120 && $image_height <= 120) {
         resizeimage($image_file, $image_file_s, 0, 120, true);
     }
     if ($image_height > 120 && $image_width > 120 && $image_width > $image_height) {
         resizeimage($image_file, $image_file_s, 120, 0, true);
     }
     if ($image_height > 120 && $image_width > 120 && $image_width < $image_height) {
         resizeimage($image_file, $image_file_s, 0, 120, true);
     }
     resizeimage($image_file, $image_file_t, 600, 0, true);
     resizeimage($image_file, $image_file_p, 180, 180, false);
     $result = array();
     $result['status'] = "ok";
     $result['image'] = $image_file;
     echo json_encode($result);
 }
开发者ID:noikiy,项目名称:LINJU,代码行数:45,代码来源:points.mod.php


示例15: define

 * @brief
 * @since version 0.85
 **/
if (!defined('GLPI_ROOT')) {
    define('GLPI_ROOT', dirname(__DIR__));
}
include_once GLPI_ROOT . "/inc/autoload.function.php";
include_once GLPI_ROOT . "/inc/db.function.php";
include_once GLPI_ROOT . "/config/config.php";
Session::checkLoginUser();
// Load Language file
Session::loadLanguage();
include_once GLPI_ROOT . '/lib/jqueryplugins/jquery-file-upload/server/php/UploadHandler.php';
$errors = array(1 => __('The uploaded file exceeds the upload_max_filesize directive in php.ini'), 2 => __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'), 3 => __('The uploaded file was only partially uploaded'), 4 => __('No file was uploaded'), 6 => __('Missing a temporary folder'), 7 => __('Failed to write file to disk'), 8 => __('A PHP extension stopped the file upload'), 'post_max_size' => __('The uploaded file exceeds the post_max_size directive in php.ini'), 'max_file_size' => __('File is too big'), 'min_file_size' => __('File is too small'), 'accept_file_types' => __('Filetype not allowed'), 'max_number_of_files' => __('Maximum number of files exceeded'), 'max_width' => __('Image exceeds maximum width'), 'min_width' => __('Image requires a minimum width'), 'max_height' => __('Image exceeds maximum height'), 'min_height' => __('Image requires a minimum height'));
$upload_dir = GLPI_TMP_DIR . '/';
$upload_handler = new UploadHandler(array('upload_dir' => $upload_dir, 'param_name' => $_GET['name'], 'orient_image' => false, 'image_versions' => array()), false, $errors);
$response = $upload_handler->post(false);
// clean compute display filesize
if (isset($response[$_GET['name']]) && is_array($response[$_GET['name']])) {
    foreach ($response[$_GET['name']] as $key => &$val) {
        if (Document::isValidDoc(addslashes($val->name))) {
            if (isset($val->name)) {
                $val->display = $val->name;
            }
            if (isset($val->size)) {
                $val->filesize = Toolbox::getSize($val->size);
                if (isset($_GET['showfilesize']) && $_GET['showfilesize']) {
                    $val->display = sprintf('%1$s %2$s', $val->display, $val->filesize);
                }
            }
        } else {
开发者ID:stweil,项目名称:glpi,代码行数:31,代码来源:fileupload.php


示例16: processImage

 public function processImage($template_id)
 {
     if (empty($template_id)) {
         return;
     }
     $this->CI->load->helper("upload");
     $path = UPLOAD_PATH . '../template/';
     $config['upload_dir'] = $path;
     $config['upload_dir'] = $config['upload_dir'];
     if (!is_dir($config['upload_dir'])) {
         //create the folder if it's not already exists
         mkdir($config['upload_dir'], 0755, TRUE);
     }
     $config['script_url'] = base_url() . $path;
     $config['upload_url'] = base_url() . $path;
     $upload_handler = new UploadHandler($config);
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
     header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'OPTIONS':
             break;
         case 'HEAD':
         case 'GET':
             //$id_template= $template_id;
             $upload_dir = dirname($_SERVER['SCRIPT_FILENAME']) . $path;
             $url = base_url();
             $files = array();
             $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : "FRONT";
             //echo $type;
             if ($images = $this->CI->template_m->get_images($template_id, $type)) {
                 foreach ($images as $img) {
                     $returnpath = $path . $template_id . '_' . $img->id_image . $this->img_extension;
                     if (file_exists($returnpath)) {
                         $file = new stdClass();
                         $file->name = $template_id . '_' . $img->id_image . $this->img_extension;
                         $file->id_image = $img->id_image;
                         $file->url = $path . $template_id . '_' . $img->id_image . $this->img_extension;
                         $file->delete_url = site_url() . '/admin/template/img_upload' . '?id_image=' . rawurlencode($img->id_image) . '&&id_template=' . rawurlencode($template_id);
                         $file->delete_url .= '&&method=DELETE';
                         $file->deleteType = 'DELETE';
                         $file->url_default = site_url() . '/admin/template/set_default/' . $template_id . '/' . $img->id_image . '/' . $img->type;
                         $files[] = $file;
                     }
                 }
             }
             $obj = new stdClass();
             $obj->files = $files;
             ob_clean();
             print_r(json_encode($obj));
             ob_flush();
             break;
         case 'POST':
             if (isset($_REQUEST['method']) && $_REQUEST['method'] === 'DELETE') {
                 $upload_handler->delete();
             } else {
                 $id_template = $template_id;
                 $type = $this->CI->input->post('type') ? $this->CI->input->post('type') : "FRONT";
                 //parent::create($this->fields);
                 if (isset($_FILES['files'])) {
                     if ($timage = $this->CI->template_m->createimage($template_id, $type)) {
                         $new_file_path = $path . $id_template . "_" . $timage->id_image . $this->img_extension;
                         if (isset($_FILES['files']['tmp_name'][0])) {
                             $file_path = $_FILES['files']['tmp_name'][0];
                             if (file_exists($file_path)) {
                                 if ($file_path !== $new_file_path) {
                                     //	 @copy($file_path, $new_file_path);
                                     $config['image_library'] = 'gd2';
                                     $config['source_image'] = $file_path;
                                     $config['new_image'] = $new_file_path;
                                     $config['maintain_ratio'] = TRUE;
                                     $config['height'] = MAX_TEMPLATE_HEIGHT;
                                     $this->CI->load->library('image_lib');
                                     $resizer = new CI_Image_lib();
                                     $resizer->initialize($config);
                                     $resizer->resize();
                                 }
                             }
                         }
                     }
                     $files_return = array();
                     //     foreach ($images as $img) {
                     $file = new stdClass();
                     $file->name = $id_template . '_' . $timage->id_image . $this->img_extension;
                     $file->id_image = $timage->id_image;
                     $file->url = $path . $id_template . '_' . $timage->id_image . $this->img_extension;
                     $file->delete_url = $this->getFullUrl() . '/admin/template/img_upload' . '?id_image=' . rawurlencode($timage->id_image) . '&&id_template=' . rawurlencode($id_template);
                     $file->delete_url .= '&&method=DELETE';
                     $file->deleteType = 'DELETE';
                     $file->url_default = site_url() . '/admin/template/set_default/' . $id_template . '/' . $timage->id_image . '/' . $type;
                     $files_return[] = $file;
                     //  };
                     $object = new stdClass();
                     $object->files = $files_return;
                     ob_clean();
                     print_r(json_encode($object));
//.........这里部分代码省略.........
开发者ID:nockout,项目名称:tshpro,代码行数:101,代码来源:Tplate.php


示例17: UploadFileHandler

 public static function UploadFileHandler($callback, $Params)
 {
     self::HealFilesVars();
     self::InitUploaderHandler();
     self::$convCount = $Params['convCount'];
     self::$uploadCallbackFunc = $callback;
     self::$uploadCallbackParams = $Params;
     self::SetTmpPath($_REQUEST["PackageGuid"], $Params["pathToTmp"]);
     $uh = new UploadHandler();
     $uh->setUploadCacheDirectory($Params['pathToTmp']);
     $uh->setAllFilesUploadedCallback(array("CFlashUploader", "SaveAllUploadedFiles"));
     $uh->processRequest();
     // Kill unsecure vars from $_POST
     self::HealFilesVars(true);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:15,代码来源:uploader.php


示例18: trim_file_name

 /**
  * Transform trimmed filename to filesystem-friendly string
  *
  * @param $file_path
  * @param $name
  * @param $size
  * @param $type
  * @param $error
  * @param $index
  * @param $content_range
  *
  * @return string
  */
 protected function trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range)
 {
     $trimmedName = parent::trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range);
     $fileNameParts = pathinfo($trimmedName);
     $slugOfName = $this->slug($fileNameParts['filename']);
     $resultFileName = $slugOfName . '.' . $fileNameParts['extension'];
     $this->setUploadedFileName($resultFileName);
     return $resultFileName;
 }
开发者ID:lagut-in,项目名称:Slim-Image-Archive,代码行数:22,代码来源:CustomUploadHandler.php


示例19: handle_file_upload

 /**
  * Override the default method to handle the specific things of the download module and
  * update the database after file was successful uploaded.
  * This method has the same parameters as the default.
  * @param  $uploaded_file
  * @param  $name
  * @param  $size
  * @param  $type
  * @param  $error
  * @param  $index
  * @param  $content_range
  * @return stdClass
  */
 protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
 {
     global $gPreferences, $gL10n, $gDb, $getId, $gCurrentOrganization, $gCurrentUser;
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (!isset($file->error)) {
         try {
             // check filesize against module settings
             if ($file->size > $gPreferences['max_file_upload_size'] * 1024 * 1024) {
                 throw new AdmException('DOW_FILE_TO_LARGE', $gPreferences['max_file_upload_size']);
             }
             // check filename and throw exception if something is wrong
             admStrIsValidFileName($file->name, true);
             // get recordset of current folder from database and throw exception if necessary
             $targetFolder = new TableFolder($gDb);
             $targetFolder->getFolderForDownload($getId);
             // now add new file to database
             $newFile = new TableFile($gDb);
             $newFile->setValue('fil_fol_id', $targetFolder->getValue('fol_id'));
             $newFile->setValue('fil_name', $file->name);
             $newFile->setValue('fil_locked', $targetFolder->getValue('fol_locked'));
             $newFile->setValue('fil_counter', '0');
             $newFile->save();
             // Benachrichtigungs-Email für neue Einträge
             $message = $gL10n->get('DOW_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $file->name, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
             $notification = new Email();
             $notification->adminNotfication($gL10n->get('DOW_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
         } catch (AdmException $e) {
             $file->error = $e->getText();
             unlink($this->options['upload_dir'] . $file->name);
             return $file;
         }
     }
     return $file;
 }
开发者ID:martinbrylski,项目名称:admidio,代码行数:47,代码来源:uploadhandlerdownload.php


示例20: handle_file_upload

 protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
 {
     $matches = array();
     if (strpos($name, '.') === false && preg_match('/^image\\/(gif|jpe?g|png)/', $type, $matches)) {
         $name = $uploadFileName = 'clipboard.' . $matches[1];
     } else {
         $uploadFileName = $name;
     }
     if (!preg_match($this->options['accept_file_types_lhc'], $uploadFileName)) {
         $file->error = $this->get_error_message('accept_file_types');
         return false;
     }
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (empty($file->error)) {
         $fileUpload = new erLhcoreClassModelChatFile();
         $fileUpload->size = $file->size;
         $fileUpload->type = $file->type;
         $fileUpload->name = $file->name;
         $fileUpload->date = time();
         $fileUpload->user_id = isset($this->options['user_id']) ? $this->options['user_id'] : 0;
         $fileUpload->upload_name = $name;
         $fileUpload->file_path = $this->options['upload_dir'];
         if (isset($this->options['chat']) && $this->options['chat'] instanceof erLhcoreClassModelChat) {
             $fileUpload->chat_id = $this->options['chat']->id;
         } elseif (isset($this->options['online_user']) && $this->options['online_user'] instanceof erLhcoreClassModelChatOnlineUser) {
             $fileUpload->online_user_id = $this->options['online_user']->id;
         }
         $matches = array();
         if (strpos($name, '.') === false && preg_match('/^image\\/(gif|jpe?g|png)/', $fileUpload->type, $matches)) {
             $fileUpload->extension = $matches[1];
         } else {
             $partsFile = explode('.', $fileUpload->upload_name);
             $fileUpload->extension = end($partsFile);
         }
         $fileUpload->saveThis();
         $file->id = $fileUpload->id;
         if (isset($this->options['chat']) && $this->options['chat'] instanceof erLhcoreClassModelChat) {
             // Chat assign
             $chat = $this->options['chat'];
             // Format message
             $msg = new erLhcoreClassModelmsg();
             $msg->msg = '[file=' . $file->id . '_' . md5($fileUpload->name . '_' . $fileUpload->chat_id) . ']';
             $msg->chat_id = $chat->id;
             $msg->user_id = isset($this->options['user_id']) ? $this->options['user_id'] : 0;
             if ($msg->user_id > 0 && isset($this->options['name_support'])) {
                 $msg->name_support = (string) $this->options['name_support'];
             }
             $chat->last_user_msg_time = $msg->time = time();
             erLhcoreClassChat::getSession()->save($msg);
             // Set last message ID
             if ($chat->last_msg_id < $msg->id) {
                 $chat->last_msg_id = $msg->id;
             }
             $chat->has_unread_messages = 1;
             $chat->updateThis();
         }
         $this->uploadedFile = $fileUpload;
     }
     return $file;
 }
开发者ID:sirromas,项目名称:medical,代码行数:60,代码来源:lhfileupload.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP UploadedFile类代码示例发布时间:2022-05-23
下一篇:
PHP UploadFile类代码示例发布时间: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