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


PHP UploadHandler类代码示例

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


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

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

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

示例13: __construct

 public function __construct($options = null, $initialize = true, $error_messages = null)
 {
     $this->options = ['csrf_token' => ['name' => '_token', 'value' => csrf_token()], 'script_url' => \URL::current(), 'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')) . '/files/', 'upload_url' => $this->get_full_url() . '/files/'];
     if ($options) {
         $this->options = $options + $this->options;
     }
     parent::__construct($this->options, $initialize, $error_messages);
 }
开发者ID:alverated,项目名称:jQuery-File-Upload,代码行数:8,代码来源:FileUpload.php

示例14: array

 function __construct($options = null)
 {
     //izveido direktoriju
     $options['upload_dir'] = self::getUploadDirPath($options['model_name']);
     $options['accept_file_types'] = Yii::app()->getModule('d1files')->accept_file_types;
     //lai netaisa thumb...
     $options['image_versions'] = array();
     parent::__construct($options, TRUE);
 }
开发者ID:dbrisinajumi,项目名称:d1files,代码行数:9,代码来源:UploadHandlerD1files.php

示例15: set_file_delete_properties

 protected function set_file_delete_properties($file)
 {
     parent::set_file_delete_properties($file);
     if ($this->delete_url != null) {
         if (substr($this->delete_url, -1) != '/') {
             $this->delete_url .= '/';
         }
         $file->delete_url = $this->delete_url . rawurlencode($file->name);
     }
 }
开发者ID:ami-m,项目名称:VxJsUploadBundle,代码行数:10,代码来源:CustomUploadHandler.php


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