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


PHP UploadHandler::get方法代码示例

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


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

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':
        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:NemOry,项目名称:BundledFunWebPanel,代码行数:31,代码来源:question_uploader.php

示例3: uploadHandler

 private function uploadHandler()
 {
     $options = array('url' => $this->createUrl("/files/", array('path' => Yii::app()->user->id . "/")), 'upload_dir' => Yii::getPathOfAlias(Yii::app()->params['filesAlias']) . DIRECTORY_SEPARATOR, 'upload_url' => $this->createUrl("/files/file"), 'script_url' => $this->createUrl("/files/uploadFile", array('path' => Yii::app()->user->id . "/")), 'field_name' => 'files', 'image_versions' => array());
     // wrapper for jQuery-file-upload/upload.php
     $upload_handler = new UploadHandler($options);
     header('Pragma: no-cache');
     header('Cache-Control: private, no-cache');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     ob_start();
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'HEAD':
         case 'GET':
             $upload_handler->get();
             $contents = ob_get_contents();
             break;
         case 'POST':
             // check if file exists
             $upload = $_FILES[$options['field_name']];
             $tmp_name = $_FILES[$options['field_name']]['tmp_name'];
             if (is_array($tmp_name)) {
                 foreach ($tmp_name as $index => $value) {
                     //$model = files::model()->findByAttributes(array('path' => Yii::app()->user->id.DIRECTORY_SEPARATOR.$upload['name'][$index]));
                     $model = new Files();
                     $attributes['path'] = Yii::app()->user->id . DIRECTORY_SEPARATOR . $upload['name'][$index];
                     $attributes['title'] = $upload['name'][$index];
                     // TODO: fix title unique check
                     #var_dump($attributes['title']);exit;
                     $model->attributes = $attributes;
                     //var_dump($attributes);exit;
                     $model->validate();
                     if ($model->hasErrors()) {
                         #throw new CHttpException(500, 'File exists.');
                         $file = new stdClass();
                         $file->error = "";
                         foreach ($model->getErrors() as $error) {
                             $file->error .= $error[0];
                         }
                         $info[] = $file;
                         echo CJSON::encode($info);
                         exit;
                     }
                 }
             }
             $upload_handler->post();
             $contents = ob_get_contents();
             $result = CJSON::decode($contents);
             #var_dump($result);exit;
             $attr = $this->createMedia($result[0]['name'], Yii::app()->params['filesAlias']);
             $result[0]['url'] .= "/" . $attr['id'];
             $result[0]['delete_url'] .= "?id=" . $attr['id'];
             $contents = CJSON::encode($result);
             break;
         case 'DELETE':
             //$upload_handler->delete();
             //$contents = ob_get_contents();
             $result = $this->deleteMedia($_GET['id']);
             break;
         default:
             header('HTTP/1.0 405 Method Not Allowed');
             $contents = ob_get_contents();
     }
     ob_end_clean();
     return $contents;
 }
开发者ID:ranvirp,项目名称:rdp,代码行数:65,代码来源:FilesController.php

示例4: uploadHandler

 private function uploadHandler()
 {
     #$script_dir = Yii::app()->basePath.'/data/p3media';
     #$script_dir_url = Yii::app()->baseUrl;
     $options = array('url' => $this->createUrl("/p3media/p3Media/update", array('path' => Yii::app()->user->id . "/")), 'upload_dir' => $this->module->getDataPath() . DIRECTORY_SEPARATOR, 'upload_url' => $this->createUrl("/p3media/p3Media/update", array('preset' => 'raw', 'path' => Yii::app()->user->id . "/")), 'script_url' => $this->createUrl("/p3media/import/uploadFile", array('path' => Yii::app()->user->id . "/")), 'field_name' => 'files', 'image_versions' => array('thumbnail' => array('upload_url' => $this->createUrl("/p3media/file/image", array('preset' => 'p3media-upload', 'path' => urlencode(Yii::app()->user->id . "/"))), 'max_width' => 80, 'max_height' => 80)));
     // wrapper for jQuery-file-upload/upload.php
     $upload_handler = new UploadHandler($options);
     header('Pragma: no-cache');
     header('Cache-Control: private, no-cache');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     ob_start();
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'HEAD':
         case 'GET':
             $upload_handler->get();
             #$contents = ob_get_contents();
             $contents = "{}";
             // we do not show existing files, since this list may get very long
             break;
         case 'POST':
             // check if file exists
             $upload = $_FILES[$options['field_name']];
             $tmp_name = $_FILES[$options['field_name']]['tmp_name'];
             if (is_array($tmp_name)) {
                 foreach ($tmp_name as $index => $value) {
                     $model = P3Media::model()->findByAttributes(array('path' => Yii::app()->user->id . DIRECTORY_SEPARATOR . $upload['name'][$index]));
                     $model = new P3Media();
                     $attributes['path'] = Yii::app()->user->id . DIRECTORY_SEPARATOR . $upload['name'][$index];
                     #$attributes['title'] = $upload['name'][$index]; // TODO: fix title unique check
                     #var_dump($attributes['title']);exit;
                     $model->attributes = $attributes;
                     $model->validate(array('path'));
                     if ($model->hasErrors()) {
                         #throw new CHttpException(500, 'File exists.');
                         $file = new stdClass();
                         $file->error = "";
                         foreach ($model->getErrors() as $error) {
                             $file->error .= $error[0];
                         }
                         $info[] = $file;
                         echo CJSON::encode($info);
                         exit;
                     }
                 }
             }
             $upload_handler->post();
             $upload_handler_output = ob_get_contents();
             $result = CJSON::decode($upload_handler_output);
             #var_dump($result);exit;
             $savedMedia = $this->createMedia($result[0]['name'], $this->module->getDataPath() . DIRECTORY_SEPARATOR . $result[0]['name']);
             $result[0]['p3_media_id'] = $savedMedia->id;
             $contents = CJSON::encode($result);
             break;
         case 'DELETE':
             $upload_handler->delete();
             $contents = ob_get_contents();
             $result = $this->deleteMedia($_GET['path']);
             break;
         default:
             header('HTTP/1.0 405 Method Not Allowed');
             $contents = ob_get_contents();
     }
     ob_end_clean();
     return $contents;
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:66,代码来源:ImportController.php

示例5: upload

 public function upload()
 {
     $_user = $this->uri->segment(1);
     $_details = $this->mFrontend->getDetailsbyURL($_user);
     if ($_details != false) {
         if ($_details->userCanUpload == '0') {
             exit;
         }
     } else {
         exit;
     }
     $this->load->helper("upload.class");
     $upload_handler = new UploadHandler();
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Vary: accept');
     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');
     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:StudsPro,项目名称:islandpeeps.com,代码行数:42,代码来源:frontend.php

示例6: uploadAction

 public function uploadAction()
 {
     if ($this->getRequest()->isPost()) {
         $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 {
                     $info = $upload_handler->post();
                     $this->_helper->json($info, true, false);
                 }
                 break;
             case 'DELETE':
                 $upload_handler->delete();
                 break;
             default:
                 header('HTTP/1.1 405 Method Not Allowed');
         }
     }
 }
开发者ID:nldfr219,项目名称:zhi,代码行数:34,代码来源:ProfileController.php

示例7: uploadFile

 /**
  * uploadFile method
  * Esta funcion es la encargada de gestionar los ficheros del 
  * usurio.
  * En projectos add gestiona (crear,eliminar)
  * En projectos edit gestiona (crear) dado que los ficheros se eliminan de la BD
  * La direccion de la carpeta del usuario se establece con la variable 
  * Configure::read('uploadFilesPath') y el mail del usuario (e mail es unico)
  * @require  App::uses('Folder', 'Utility');
  * @require App::uses('File', 'Utility');
  * @require UploadHandler.php
  * @throws exception
  * @return void
  */
 public function uploadFile($projectId = null)
 {
     App::import('Vendor', 'uploader', array('file' => 'jQuery-File-Upload' . DS . 'UploadHandler.php'));
     App::uses('Folder', 'Utility');
     App::uses('File', 'Utility');
     $uploadPath = Configure::read('uploadFilesPath');
     $filesAllowed = Configure::read('filesAllowed');
     $maxUploads = Configure::read('max_upload_files');
     $maxFileSize = $this->filesize2bytes(Configure::read('max_file_size'));
     if ($maxUploads == 0) {
         $maxUploads = 99999;
     }
     $path = $uploadPath;
     //para que no moleste con los permisos
     //ini_set("display_errors", 0);
     //error_reporting(0);
     $this->autoRender = false;
     $email = $this->Auth->user('email');
     //si no esta logueado
     if (!$this->Auth->loggedIn()) {
         print "One joker!!";
         exit;
     } else {
         $folder = new Folder();
         //si se puede crear la carpeta
         if ($folder->create($path)) {
             //chmod($path, 0600);
             //                $path = $path . DS . $email;
             $path = $path . DS . tempnam(sys_get_temp_dir(), '');
             if ($folder->create($path)) {
                 //si no existe la carpeta se crea
                 $folder = new Folder($path, true, 0700);
                 //chmod($path, 0600);
                 $absolutePath = $folder->path . DS;
                 $options = array('script_url' => Router::url(array('controller' => 'ProjectResources', 'action' => 'uploadFile')), 'upload_dir' => $absolutePath, 'upload_url' => $this->webroot . $path . DS, 'user_dirs' => false, 'mkdir_mode' => 0700, 'param_name' => 'files', 'delete_type' => 'DELETE', 'access_control_allow_origin' => '*', 'access_control_allow_credentials' => false, 'access_control_allow_methods' => array('OPTIONS', 'HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'), 'access_control_allow_headers' => array('Content-Type', 'Content-Range', 'Content-Disposition'), 'download_via_php' => false, 'accept_file_types' => '/(\\.|\\/)' . $filesAllowed . '$/i', 'max_file_size' => $maxFileSize, 'min_file_size' => 1, 'max_number_of_files' => $maxUploads, 'max_width' => null, 'max_height' => null, 'min_width' => 1, 'min_height' => 1, 'discard_aborted_uploads' => true, 'orient_image' => false);
                 $upload_handler = new UploadHandler($options, false);
                 switch ($_SERVER['REQUEST_METHOD']) {
                     case 'HEAD':
                     case 'GET':
                         throw new Exception();
                         $upload_handler->get();
                         break;
                     case 'POST':
                     case 'PUT':
                         $group_id = $this->Session->read('group_id');
                         if ($group_id == 1) {
                             $this->ProjectResource->Project->id = $projectId;
                             if (!$this->ProjectResource->Project->exists()) {
                                 throw new NotFoundException(__('Invalid project '));
                             }
                             $response = $upload_handler->post();
                             $packagedFiles = array();
                             $files = $folder->find('.*.' . $filesAllowed);
                             if (!empty($files)) {
                                 foreach ($files as $file) {
                                     $file = new File($folder->pwd() . DS . $file, 644);
                                     if ($file->readable()) {
                                         //                                        $md5 = $file->md5();
                                         $name = $file->name();
                                         $ext = $file->ext();
                                         $content = $file->read();
                                         $fileSize = $file->size();
                                         $file->close();
                                         $data = array('name' => $name, 'file' => $content, 'extension' => $ext, 'project_id' => $projectId, 'size' => $fileSize);
                                         $this->ProjectResource->create();
                                         if ($this->ProjectResource->save($data)) {
                                             $packagedFiles[$name . "." . $ext] = $this->ProjectResource->id;
                                         }
                                     }
                                 }
                                 if (!empty($packagedFiles)) {
                                     $files = $response['files'];
                                     $size = sizeof($files);
                                     for ($index = 0; $index < $size; $index++) {
                                         $file = $files[$index];
                                         if (isset($packagedFiles[$file->name])) {
                                             $file->url = Router::url(array('controller' => 'ProjectResources', 'action' => 'downloadFile', $packagedFiles[$file->name], $projectId));
                                             $file->deleteUrl = Router::url(array('controller' => 'ProjectResources', 'action' => 'deleteFile', $packagedFiles[$file->name], $projectId));
                                         } else {
                                             $file->error = "Could not be saved";
                                         }
                                     }
                                     return $this->correctResponseJson($response);
                                     //                                            $this->correctResponseJson(array("error" => "Could not be saved"));
                                 }
                             }
//.........这里部分代码省略.........
开发者ID:sing-group,项目名称:Markyt,代码行数:101,代码来源:ProjectResourcesController.php

示例8: _loader

 public function _loader()
 {
     $upload_handler = new UploadHandler();
     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');
     //$fp=fopen("log.txt","w");
     //fwrite($fp,"QUEST:".$_POST["upselect"]);
     //fclose($fp);
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'OPTIONS':
             break;
         case 'HEAD':
         case 'GET':
             /*$fp=fopen("log.txt","w");
               fwrite($fp,"QUEST:".$_GET["name"]); 
               fclose($fp);*/
             $upload_handler->get($_GET["name"]);
             break;
         case 'POST':
             $upload_handler->post();
             //写入数据库。其中imagegroupID从$_POST["upselect"]得到,imageurl从$upload_handler->filepathout得到。
             if (!$upload_handler->error) {
                 $name = $upload_handler->name;
                 $url = $upload_handler->filepathout;
                 $fp = fopen("log.txt", "a");
                 fwrite($fp, "NEW:" . $url . "\r\n");
                 fclose($fp);
                 $groupID = $_POST["upselect"];
                 $imgmd = new image();
                 $data = array($name, "", $_SESSION["USERID"], date("Y-m-d"), $url, $groupID, '', '');
                 $imgmd->model->New($data);
                 $act = new active();
                 $img = new stdClass();
                 $img->gid = $groupID;
                 $img->d = $url;
                 $img->ti = time();
                 $img->gn = "xxxx";
                 $act->_new($_SESSION["USERID"], 1, $img);
             }
             break;
         case 'DELETE':
             $upload_handler->delete();
             $file_name = isset($_REQUEST['file']) ? basename(stripslashes($_REQUEST['file'])) : null;
             $url = $file_name;
             $imgmd = new image();
             $imgmd->model->Del_By_imgurl($file_name);
             $act = new active();
             $img = new stdClass();
             $img->d = $url;
             $img->ti = time();
             $act->_del($_SESSION['USERID'], $img);
             break;
         default:
             header('HTTP/1.1 405 Method Not Allowed');
     }
 }
开发者ID:RaoHai,项目名称:picpic,代码行数:61,代码来源:controller.user.class.php


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